Let's say that I'm forking repo
After the repo has been forked to my repository I will clone it on my local machine.
1git clone email@example.com:neerajdotname/rails.git
cd rails and execute
git remote -v . This is what I see.
1origin firstname.lastname@example.org:neerajdotname/rails.git (fetch) 2origin email@example.com:neerajdotname/rails.git (push)
Now I will add
upstream remote by executing following command.
1git remote add upstream firstname.lastname@example.org/rails/rails.git
After having done that when I execute
git remote -v then I see
1origin email@example.com:neerajdotname/rails.git (fetch) 2origin firstname.lastname@example.org:neerajdotname/rails.git (push) 3upstream git://github.com/rails/rails.git (fetch) 4upstream git://github.com/rails/rails.git (push)
Now I want to make some changes to the code. After all this is why I forked the repo.
Let's say that I want to add exception handling to the forked code I have locally.
Then I create a branch called
and make all your changes in this branch.
The key here is to not to make any changes to
I try to keep master of my forked repository in sync with the master of the original repository where I forked it.
So now let's create a branch and I will put in all my changes there.
1git checkout -b exception-handling
Gemfile I will use this code like this
1gem 'rails', github: 'neerajdotname/rails', branch: 'exception-handling'
A month has passed. In the meantime rails master has tons of changes. I want those changes in my
exception-handling branch. In order to achieve that first I need to bring my local master up-to-date with rails master.
I need to switch to master branch and then I need to execute following commands.
1git checkout master 2git fetch upstream 3git rebase upstream/master 4git push
Now the master of forked repository is in-sync with the master of
rails/rails. Now that master is up-to-date I need to pull in the changes in master in my
1git checkout exception-handling 2git rebase master 3git push -f
Now my branch
exception-handling has my fix on top of rails master.