[ell-i-developers] Some advice with git pull

  • From: Pekka Nikander <pekka.nikander@xxxxxx>
  • To: ell-i-developers@xxxxxxxxxxxxx
  • Date: Tue, 4 Mar 2014 07:49:22 +0200

> To update my local repository, would simple git pull from command line would 
> work?

Depending on how large changes you have in your local repository, and whether 
you have already committed your changes locally, it may or may not work.  
However, Eero provided me already with a pull request, which I just integrated. 
 Hence, if you have any trouble, the easiest thing is to start a new repository 
with a new git clone.

In general, in order to be able to do a git pull, you have to have your local 
repository clean.  That either means that you either use "git stash" to 
temporarily store your local changes, you commit your local changes first, or 
your otherwise clean up your repository.  After that, you should be able to do 
git pull without any problem.  Please make sure that you also have made your 
local repository to do pulls by rebase, as explained in the previous best 
practises mail:


My current recommendation is to commit the local changes always before doing a 
git pull.  If you are not happy with your local changes, you can first commit 
them into a temp branch:

  git checkout -b temp-xxx-yyy
  git add ...
  git commit -m "Temp commit for xxx yyy"
  git checkout master

After that your changes are committed into the temp branch, and visible there:

  git log temp-xxx-yyy

However, they cannot be seen in the working copy or in the master branch.

Now you can easily pull to the (now clean) working copy and master:

  git pull --rebase origin/master

(or if you want to avoid history rewriting, git pull --ff-only origin/master)

Now you have your own local changes in the temp-xxx-yyy branch and the latest 
upstream in your local master.

The next step is then to re-apply your local changes to the now-updated local 

I usually use "git cherry-pick" for that.  I think "git cherry-pick 
..temp-xxx-yy" should work, but I haven't done in that way for a while, as I 
more often apply the commits one-by-one.


Other related posts:

  • » [ell-i-developers] Some advice with git pull - Pekka Nikander