tags:

views:

33

answers:

3

Hi,

I have download a git repository locally using this:

git clone git://git.webkit.org/WebKit.git WebKit

I am using that a own experiment (not intended to push the changes back to webkit.org). So I made some changes and do then 'git commit'.

But I would like to find out what is the best way for me to update my Webkit repository (as I may made file changes which have been changed/modified remotely).

I did some digging. There are different ways in git?

1. git pull
2. git pull --rebase

So which one is best for my situation?

Thank you.

A: 

The best way to do go about committing your own changes is to commit them into a separate branch. Then you can merge or rebase updates from master or any other branches that are published.

By keeping the master branch clean of your changes, it does not matter if you git pull or git pull --rebase on the master branch. All the merging that the git pull command do will end up as what are know as "fast-forward merges". This simply means there is nothing to merge so it is a simple pointer movement of the master branch to the latest commit you got from the remote.

Hope this helps,

Adm

adymitruk
A: 

You should try to avoid git pull, and use git fetch + git merge. This blog has more information

phsr
A: 

The git pull command will get the latest changes from the source (origin by default) and immediately try to merge them with your code in your current branch. If there's no overlap, it will be a breeze.

git pull --rebase will do the same, except it'll try to apply your changes onto the end of the stream of incoming ones so they look like one simple progression. You would only notice the difference if you looked at the history (git log) from both methods. (See this page for a demo.)

If you're concerned about overlap of your changes with ones from the origin and would like a "preview" before you attempt to merge them, then you could use the command git fetch origin to bring down all the latest changes into a hidden local branch called 'origin/master'--which is different than your 'master' branch. You could then choose to browse around it by git merge origin/master (note that you will see a warning message that this isn't a "real" branch, but it still works), and later merge it with your code (first git checkout master if you weren't already there, then git merge origin/master).

(As adymitruk mentioned, it is easiest to make your changes in a separate branch (git checkout -b my_branch), and then fetch-and-merge or pull. But if you've already been working on the local master branch, the aforementioned commands will get you there.)

ewall