-
Notifications
You must be signed in to change notification settings - Fork 47
How to git for svn users
This HOWTO page is for old-school subversion guys (like me) who trying to contribute for qcubed on github with git. It is intended to provide some common knowledge of how to use git in the qcubed workflow context - Workflow. We assume that you already have github registration and qcubed framework clone in it.
-
Create a local branch for every qcubed remote branch you are interested in:
git checkout master
git checkout -b feature-XXX
git pull git@github.com:qcubed/framework.git feature-XXX
git checkout master
git checkout -b feature-YYY
git pull git@github.com:qcubed/framework.git feature-YYY
-
Do not forget to go to your master before you make your own feature- branch:
git checkout master
git checkout -b feature-MyFeature
-
If you have merged some code to your master branch you can revert it with:
git reset --hard origin/master
-
If you have merged some code to your master branch and accidentially pushed it, you can revert it with:
git push -f origin a5c1da92097ff067849221b5556ac90d2cf4d798:master
git reset --hard origin/master
Where a5c1da92097ff067849221b5556ac90d2cf4d798 is an example of a commit where you want return to.
-
If you made some changes to a branch and you want to revert locally, do the following:
git reset --hard HEAD
(reverts any uncommitted changes)git reset --hard HEAD^
(reverts to 1 commit before the latest commit)git reset --hard HEAD~5
(reverts back 5 commits)
gitk is also good for doing this sort of thing. It is a GUI util that gives you a visual overview of everything that is happening with the repository. It shows you what branches point to what commits, gives you diffs for each commit, shows commit messages, and does a lot of other really handy stuff. This article explains how to make life easier using gitk and is written by a guy that used it to make the transition from svn to git.