tags:

views:

35

answers:

2

I have a local branch that is tracking of a remote branch on git. At some point I update file 'x.out', but while working on this branch I try to pull from the server latest changes. Somebody else already updated 'x.out' and git tells me that "cann't overwrite file" (or so) so I must add my changes to the index and ALSO commit my change before beeing able to pull succesfully.

  1. Issue is that with this approach it results in 2 commits in the repository: one commit for my local change (because I had an older version from server of 'x.out' ) and one commit after I "git add" my modified 'x.out' file (that basically sais "merge branch ..")

  2. I don't want this 2 steps commits (the logs look terrible also) - it's hard to follow what should have been a single commit. Isn't there a way like in SVN/Perforce to tell when pulling that I want my local modified file merged with that from server (if automatic merging is possible if not to merge the conflict?) That way when pulling to remote again there is this just only 1 commit and not 2 commits...

+2  A: 

You could try git pull --rebase, which may alleviate the situation somewhat.

All in all though, there really isn't anything wrong with having an extra commit. Just get an application like gitk or gitg, which visualise the log nicely.

Matthew Scharley
actually after some more days of playing with this situation I've come to the conclusin that rebasing solves this issue nicely.
Ghita
+2  A: 

You have to pull the changes, and clean the conflicts (if any) locally.

$ git pull
 ...
file foobar not up to date, cannot merge.
$ git stash
$ git pull
$ git stash pop

And then remove conflict and add the file.

simplyharsh
right. This is just what I wanted. This way one can work on a tracking branch directly and pull at his convenience. Thanks !
Ghita