Learning the git workflow takes a bit of brain retraining, but since I've been using SVN almost entirely via commandline (because Subversive sucks and locks up my Eclipse when I try to use it for anything beyond synching/updating/committing a handful of files), adopting git's commandline syntax is reasonably similar. Consider these simple operations:
Initial checkout from existing repo for a given branch | git clone http://github.com/sonatype/sonatype-tycho.git; cd sonatype-tycho; git checkout origin/tycho-0.10.x | svn checkout http://anonsvn.jboss.org/repos/jbosstools/branches/jbosstools-3.2.0.Beta1/ |
---|---|---|
Update locally checked out files from central repo | git pull | svn update |
List locally changes files/folders | git status | svn stat |
Diff locally changed file | git diff somefile.txt | svn diff somefile.txt |
Revert locally changed file* | git checkout somefile.txt | svn revert somefile.txt |
Revert ALL local changes (except untracked files)* | git reset --hard HEAD | svn revert . -R |
Add new file | git add file.txt | svn add file.txt |
Add new folder recursively | git add folder | svn add folder |
Delete file | git rm file.txt | svn rm file.txt |
Delete folder | git rm -r folder (non-recursive by default; use -r to recurse) | svn rm folder (recursive by default; use -N to not recurse) |
Commit changed file to central repo | git commit -m "message" file.txt; git push | svn ci -m "message" file.txt |
Ignore files/folders (in the current folder) | echo "target *.class bin" > .gitignore; \ git ci -m "gitignore" .gitignore | svn propset svn:ignore "target *.class bin" .; \ svn ci -N -m "svn:ignore" . |
Obviously you can do a lot more w/ Git than with SVN (like stashing local changes temporarily), but for the sake of simply moving from a VCS to a DVCS and being able to continue to work the same way you already do, the above table should provide a good introduction.
7 comments:
You seem to have forgotten the command to update files with the changes coming from the central repository. (svn update, git-pull)
If you still have to interface with SVN repositories but want to use git as well (great for large renaming projects and doing local continuous integration builds). You can use the "git svn" command set.
"git svn clone urltoclone" will get you started, and get you full history locally.
You can then do all normal git operations, to update, use:
git svn rebase
to commit your changes back to svn:
git svn dcommit
You have the advantage of git, and still can use svn when you have too.
@jhominal, thx. Added to the list.
@d_a_caver - good idea. More interested in a way to move away from CVS to git. Have you ever played with git-cvsserver, or any of the cvs import tools?
@nickb: avoid trying to round trip from git back to cvs, it is just not there.
@dave I have no desire to round trip. I want to export from CVS to Git and move forward, never looking back.
Thanks, this is what I was looking for. I am currently migrating all our SVN projects to Git.
even the size also matters when you do a checkout vs clone
http://techidiocy.com/understand-git-clone-command-svn-checkout-vs-git-clone/
Post a Comment