On Sep 30, 2007, at 4:48 PM, Bruno Haible wrote:
Hello Jim,- Did "git pull". It told me:Then (everything is committed), you switch to the trunk and pull (update from public repo) from there: git checkout master git pull then go back to your branch and use git-rebase to make your branch change set(s) apply cleanly to the new tip of the trunk: git checkout branch-B git rebase master The rebase is where you'll resolve any conflicts.OK, then my problem was that I did "git pull" without a rebase step.
You shouldn't pull if you want to rebase. Read man git-pull, it clearly states that pull = fetch + merge in current branch. If you want to rebase, you don't want to merge. That's why you had to solve conflicts twice (once for merge, once for rebase). The resulting commit tree will also have an extra commit (that of the merge done by git-pull) which is stupid since the goal of rebase is to preserve a linear history and have your commits on top of it (so why add merge- commits if there is no merge in the end?).
Remember that I don't like to use "git checkout", because I want to memoize my working topic by directory name, and not have git modify my source filesunnecessarily when I have built object files in the same directory.In this situation, I wanted to use "git pull" just to update my changes and let me reduce conflicts. This is not the moment where I want to startbookkeeping (adding files, thinking about a commit message etc.) $ git checkout master M ChangeLog Already on branch "master" $ git pull Updating 61135ee..0f0eb9b ChangeLog: needs update fatal: Entry 'ChangeLog' not uptodate. Cannot merge.
You can't merge (and thus can't pull) if your tree is not clean. Possible solutions:
1. commit your change if it's ready for commit. 2. stash your changes away (man git-stash, requires git >= 1.5.3) I personally use git-stash: $ git stash $ git pull / fetch+rebase <solve conflicts + commit> $ git stash apply $ git stash clear # unless you want to keep the stash
$ git rebase master ChangeLog: needs update What am I supposed to do here?- "git fetch" does too not enough: it only fetches changes but does notstore them in my "master" branch.
It stores them in your remote master master IIRC. pull will simply do that + merge in your current branch (which happens to be your local master branch).
- "git rebase master" without "git add" does nothing; "git rebase master" after "git add" tells me "Current branch master is up to date.".
You must have a pristine tree+index in order to use rebase/merge.Here is what you should do if you want to achieve what I think you're trying to achieve:
$ git branch -a * master origin/HEAD origin/master(if you have color.branch=auto in your conf, you will easily notice that origin/* are remote branches while master is local)
$ git fetch remote: Generating pack... [...] 100% (3/3) done* refs/remotes/origin/master: fast forward to branch 'master' of /tmp/ foo/ref/
old..new: 7b910f5..3e9ae50Now the new commits have been fetched in origin/master (have a look at git log: your local branch is unchanged, now have a look at git log origin/master, the new commits appeared there). Now you want to preserve linear history, so let's rebase:
$ git stash # If you have a non-committed changes $ git rebase origin/master <maybe: solve conflicts, commit> $ git stash apply # restore your non-committed changes <maybe: solve conflicts> $ git stash clear # get rid of the stash Pitfalls: - git stash does not stash untracked files. http://marc.info/?l=git&m=119109247220712&w=4 - git push can push the stashed trees. http://marc.info/?l=git&m=119089831513994&w=4- Changing branch while having uncommitted changes will work and keep the changes (if the merge is not trivial, otherwise it will bail out with an error).
http://marc.info/?l=git&m=118975544126497&w=4 Hope this helps. Cheers, -- Benoit Sigoure aka Tsuna EPITA Research and Development Laboratory
PGP.sig
Description: This is a digitally signed message part