Show Menu
Cheatography

Git-SVN Cheat Sheet by

Yet another Git-SVN cheat sheet, based on http://www.cheatography.com/ezk/cheat-sheets/git-svn-for-beginners/

Setting up a git-svn working copy

Checkout an SVN repository
git svn clone -s <ur­l_t­o_s­vn_­rep­o> [--pre­fix­=or­igin/]
The -s option is used to specify that the SVN repo has the standard file tree; the
--prefix
option specifies the prefix for remote branches naming
Reflect & track remote ignores
git svn show-i­­gnore > .gitignore

Staging and committing changes

Add file/stage changes
git add <fi­le> [--all]
The command is recursive; the
--all
option forces to stage deletions
Commit staged changes
git commit [-m <me­ssa­ge>]
Add and commit all changes
git commit -a [-m <me­ssa­ge>]
Commit changes to the SVN repo
git svn dcommit [--rmdir]
The
--rmdir
option forces the deletion of empty direct­ories

Undoing things

Revert unstaged changes
git checkout <fi­le>
Revert staged changes
git reset HEAD <fi­le>
Revert committed changes
git revert <re­v_h­ash>
The revision hash can be
HEAD
if you want to undo your latest commit (see the docume­ntation of the
revert
subcommand for additional detail

Working with branches

Create a branch on the SVN repo
git svn branch <br­anc­h_n­ame> [--par­ents]
This has to be done if you want the branch to be committed to the SVN repo; the
--parents
option forces the creation of parent direct­ories if needed
Create a local git branch based on an existing SVN branch
git checkout -b <lo­cal­_br­anc­h> <sv­n_b­ran­ch>
This will keep both branches in sync
Be careful: if you rebase a branch on another, you might break something.
Make sure you run
git svn info
when you want to push modifi­cations to an SVN branch to make sure you are committing to the approp­riate branch: a broken SVN repo is hard to fix.

Useful resources

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.