Skip to content

How to git for svn users

olegabr edited this page Mar 7, 2013 · 8 revisions

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.

  1. 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

  2. Do not forget to go to your master before you make your own feature- branch:

    git checkout master

    git checkout -b feature-MyFeature

  3. If you have merged some code to your master branch you can revert it with:

    git reset --hard origin/master

  4. 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.

  1. 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.

Clone this wiki locally