I'm a former svn user too and now use git for all my projects.
When using git, you should change your way of thinking from the client-server architecture that's used in svn. In svn, every change needs a connection with the server. Using git, your repo is in the working directory. You don't need a connection for every repo action.
Only use git push
and git pull
to synchronise with the repo. Think of it as using rsync or any backup solution to make two places have exactly the same content. Just like when you connect external backup hard disk, then make the content in it same with the content in your main. That's the usage of git pull
and git push
.
If you just want to go back and forth in the history, do it using git checkout
. See the revision id using git log
. If you're using Linux, use gitk
to see the revision tree. In Windows, tortoise git can display it using revision graph.
To get back to latest revision, use git checkout master
. Before doing any command, always make yourself do git status
. This command will display anything you need to know about current repo condition, and what action you need to do to make it right. Before doing git pull
and git push
, it's better to make sure that the git status
result shows working directory clean
.
If you need to revert a file to its previous revision, you can do it with git merge
. Before doing it to a file, test it first with git diff
. Ex: git diff rev1:rev2 filename
. It will print out any differences between two revisions. Changes in rev1 will be replaced by the changes in rev2. So to do revert, rev2 will be the older than rev1. After you are satisfied with the diff result, do it with git merge
, just replace diff
with merge
and all other parameters stay the same.
I hope this helps you. The main key is to see that your working dir is your repo. Understanding this will help you use git to it's full capability. Good luck.
git pull
altogether. Instead, I usegit fetch --all
aliased togu
in bash, and havegitk
open all the time, viewing all branches - see View -> edit -> check all 4 checkboxes. Then I move usinggit reset
orgist stash
+git co
, depends on what I need. – Collusion