Merge in git: via git-svn, says already updated, but git-diff says there are differences
I am using git-svn to work with my codebase and I need to merge the changes in trunk into my branch.
I have two branches checked out in git and when I run git diff trunk while in my branch I can see all the changes.
When running git merge chapters / trunks, however, I get the message "Already updated".
It is clearly not being updated. What am I doing wrong?
a source to share
"Already updated" can mean:
- trunk is the parent of the master (all changes from the trunk have already been merged into the master)
- or you are working on a detached head (this can happen if you check the SHA1 reference or tag directly).
Note: remember git svn caveats
Subversion doesn't have merge tracking, and as a result, forked development with Subversion can be cumbersome.
While itgit svn
can track copy history (including branches and tags) for repos using the standard layout, it cannot yet represent the merge history that happened inside git back upstream to SVN users.
Therefore, it is recommended that users keep history as linear as possible within git, in order to simplify SVN compatibilityFor simplicity and interoperability with a less capable system (SVN), it is recommended that all
git svn
usersclone
,fetch
anddcommit
be directly from the SVN server, and avoid everyonegit clone/pull/merge/push
between repos and git branches.
The recommended method for sharing code between branches and git users isgit format-patch
andgit am
, or just 'dcommit'ing into the SVN repository.
a source to share
Nothing like an example. Here's how to get into this situation:
(starting with an empty directory):
> git init > echo "hello"> a.txt > git add -A > git commit -m "Created a on master" > git branch test > git checkout test
At this point a.txt are identical on main and test branches
> echo "goodbye"> a.txt > git add -u > git commit -m "Changed a on test"
Now (obviously) there will be differences:
> git diff --name-status master M a.txt
still git has nothing to merge:
> git merge master Already up-to-date.
This is because the changes were made here in testing, not on master. If you switch to test, diff will report it similarly, but now the merge merges with changes from test to master:
> git checkout master > git diff --name-status test M a.txt > git merge test Updating 088cd9d..3d8c8e2 Fast-forward a.txt | 2 + - 1 files changed, 1 insertions (+), 1 deletions (-)
Git Merge is directional, merging from branch A to B is not the same as merging from B to A.
a source to share