GIT Clones on multiple machines
Here's my setup ...
Notebook (Mac) - git clone of svn repository
Thumb drive - git clone notebook git repository
Server (Win Server 08) - git clone of flash storage
I'm having trouble getting them to sync for some reason ...
If I make changes on the server, I do a "git pull" on the flash drive to get the changes. Take the flash drive to your laptop and "git pull" on your laptop. From there I can do "git svn dcommit" and everything goes to the SVN repo without issue.
If I check out the changes from SVN with "git svn rebase" and then flush out to flash and do "git status" it says I ## revisions ahead of master / origin and I can't figure out why.
Server
>git remote show
origin
>git remote show origin
* remote origin
Fetch URL: E:/proj
Push URL: E:/proj
HEAD branch: master
Remote branch:
master tracked
Local ref configured for 'git push':
master pushes to master (local out of date)
Laptop
>git remote show
(nothing)
>git remote show origin
fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
Thumb disc
>git remote show
origin
>git remote show origin
* remote origin
Fetch URL: /Users/me/ui/proj
Push URL: /Users/me/ui/proj
HEAD branch: (unknown)
Remote branch:
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
a source to share
Git commands like pull don't work with permutations.
Let's say that on your laptop you have some commits that are not in svn yet, and the flash drive is synced. Something like that:
laptop:
svn1 -- svn2 -- A -- B -- C -- D
thumb drive:
svn1 -- svn2 -- A -- B -- C -- D
Then you do git svn rebase to get the new stuff from svn. It works in two steps:
laptop (after fetching from svn)
svn1 -- svn2 -- svn3 -- svn4
\
+ A -- B -- C -- D
We now have to put your git work on top of the new svn commits, so we still have a non-forked history. This is the rebase part:
laptop (after git svn rebase)
svn1 -- svn2 -- svn3 -- svn4 -- A' -- B' -- C' -- D'
Now, if there are no conflicts, commit A 'contains the same changes as old commit A, the only one being its ancestor: svn4 instead of svn2. Since history is part of every commit in git, different commits are used for git A and A '.
So, after you git pull
go from the laptop to the thumb repository, git does what comes naturally to it, which is merging the new changes:
thumb drive (after git pull)
svn1 -- svn2 -- svn3 -- svn4 -- A' -- B' -- C' -- D'
\ \
+ A -- B -- C -- D -------------------- merged result
This makes sense in git as it allows you to track all changes in a non-linear environment and take into account who did the merges and how. However, you will not be able to transfer this history to svn.
If you forcibly pushed the changes to the thumb repository, you would end up with something like this:
thumb drive (after forced push)
svn1 -- svn2 -- svn3 -- svn4 -- A' -- B' -- C' -- D'
which is fine if you haven't made any changes to the flash drive repository. If you did, it would overwrite them. To save your changes with your thumb, you need to do another one git rebase
.
I would say that in order to fully use git, you will have to give up being able to pipe your work to svn. There is no easy way to have distributed versioning and linear histories at the same time.
a source to share
This is because the code will git svn rebase
restore any commits to the repository. If any git commits that you have made the upstream repository inactive, the commit id will change and your other repos will not see the change yet. This is my best guess right now. Your workflow is a little confusing for me. An ascii diagram might help a little, but it will work a little;)
In my opinion, the best way to do this might be git push -f ...
on your flash drive after each git svn rebase
. Basically, force a flash drive upgrade. But honestly, I'm not a git guru.
a source to share