Practise Git

Practise Git


Table of Contents

  • What's git?
  • Daily Usage

1 What's git?

Git, initially started by Linus, is a most advanced distributed version control system. The another kinds of version control system are centralized version control system, SVN is one of them.

2 Daily Usage

  • you wanna stage a file
git add file
  • untrack(unstage) a file
git reset HEAD file
  • get a diff between staged area and unstaged area
git diff
  • get a diff between staged area and last commitment
git diff --cached
  • commit staged area into the repository
git commit
  • push to the last commitment into the remote repository
git push [remote-name] [branch-name]
git push [remote-name] [locale-branch]:[remote-branch]
  • remove staged file
git rm file
#or 
git reset HEAD file
rm file
  • turn back to former status
git checkout -- file
  • get a list of all remote repository
git remote -v
  • add a remote repository
git remote add [shortname] [url]
  • fetch data from remote repository
git fetch [remote-name]
  • check remote repository's information
git remote show [remote-name]
  • rename and delete remote repository
git remote rename [remote-name1] [remote-name2]
git remote rm [remote-name]
  • add tag
git tag
git tag -l "v1.2.*"
git tag -a v1.4 -m 'my version 1.4' [hash value]
git show v1.4
  • share the tag
git push [remote-name] v1.5
git push [remote-name] --tags
  • branch
git branch [new-branch]
git checkout [new-branch]
git branch -d [new-branch]
  • delete remote repository's branch
git push [remote-name] :[branch-name]
  • rebase
always use rebase in the local repository, the primary difference between rebase and merge is that rebase can make more clean commitment history. Never and ever rebase remote branch.

rebase two local branches:

git checkout [branch1]
git rebase [branch2]
# after solved all of the conflicts, then 
git rebase --continue

Comments

Popular posts from this blog

Bluedroid stack in android

How to setup a NAT server?

Network programming in elisp