Practise Git
Practise Git
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
- 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
rebase two local branches:
git checkout [branch1] git rebase [branch2] # after solved all of the conflicts, then git rebase --continue
Comments
Post a Comment