Cheatography
https://cheatography.com
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 <url_to_svn_repo> [--prefix=origin/]
|
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-ignore > .gitignore
|
Staging and committing changes
Add file/stage changes |
git add <file> [--all]
|
The command is recursive; the --all option forces to stage deletions |
Commit staged changes |
git commit [-m <message>]
|
Add and commit all changes |
git commit -a [-m <message>]
|
Commit changes to the SVN repo |
git svn dcommit [--rmdir]
|
The --rmdir option forces the deletion of empty directories |
Undoing things
Revert unstaged changes |
git checkout <file>
|
Revert staged changes |
git reset HEAD <file>
|
Revert committed changes |
git revert <rev_hash>
|
The revision hash can be HEAD if you want to undo your latest commit (see the documentation of the revert subcommand for additional detail |
Working with branches
Create a branch on the SVN repo |
git svn branch <branch_name> [--parents]
|
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 directories if needed |
Create a local git branch based on an existing SVN branch |
git checkout -b <local_branch> <svn_branch>
|
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 modifications to an SVN branch to make sure you are committing to the appropriate branch: a broken SVN repo is hard to fix.
|
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment