How to update / synchronize the master of my repository in github with the original master

5

Using the command line, how can I update / synchronize my master with the original master where I made fork .

What different ways and options are the best, and how the history is affected / recorded.

    
asked by anonymous 31.01.2014 / 08:34

2 answers

8

What I usually do is:

First, I make an original project fork on Github (eg link )

Then a clone from my Github repository on my machine:

$ git clone [email protected]:jpkrohling/gatein-portal.git

At this point, you have a remote called "origin". Then add another one, called "upstream", that points to the original:

$ git remote add upstream [email protected]:gatein/gatein-portal.git

From time to time, sync:

$ git checkout master
$ git fetch upstream
$ git rebase upstream/master

After doing the above rebase, my local master is exactly the same as the upstream master, just needing to update the github version:

$ git push origin master

I have the habit of working only on topics (ie: every new feature, a new branch). When I finish the work, I send this branch to github:

$ git push 

So, from github itself, I make a pull request from the commits in the branch to the upstream master. My master never receives my commits directly, which makes it easier to synchronize, since I consider the master to be a starting point for any new feature. When the commits of my branch are accepted in upstream / master, they arrive in my master at the next synchronization.

    
31.01.2014 / 10:03
2

You can use Hub , to execute a pull request just use the command:

git pull-request [-f] [-m MESSAGE|-F FILE|-i ISSUE|ISSUE-URL] [-bBASE] [-h HEAD]

Source: pull-request manpage :

You can also use the GitHub CLI

ghi pull-request [user] [branch]

Or, using GitHub Gem :

gh pull-request [user] [branch]
    
31.01.2014 / 09:36