This article first appeared in the personal micro-channel public number "andyqian", look forward to your attention ~
Git's birth
In business development, the source code version control tool is already the norm. If you have not used version control tool, it is a very wrong. Say the version control tool, is now more popular SVN and Git. Here we introduce today is Git, Git birth is very interesting, Linux system we all know it, its founder Linus in the development of it, because Linux is open source system, a few people began to participate, are Linus himself diff manually by the combined codes. Even though the original inefficient, Linus is not willing to quote centralized version control tools SVN or CVS. Until the growing influence of the community, it is also growing amount of code to submit, a small community partners to introduce strong vocal version control tools, not bow to SVN and CVS tools such as Linus. A reference to the final commercial version control tool: BitKeeper. BitKeeper's owner BitMover company out of humanitarian spirit, authorize the use of Linux for free. But it did not last long, Linux community is not complacent brothers, want to break their play. BitMover company only to be found, huff to recover the right to use BitKeeper free of Linux. Not recover it does not matter, a very, very withdrawn. Linus how you may be able to? Angrily spend a few days time to develop their own version control tool, that is, we now use Git. (Cow is the cow!)
Git common commands
Here are some common Git version control commands in their daily work is also often used. Git command very much, we may not remember all the living, but the help command git help is sure to remember.
Initial Configuration
-
Set the user name, e-mail (e-mail will be reflected in the record)
$ git config --global user.name "user_name" $ git config --global user.email "user_email"
-
set proxy (optional)
git config --global http.proxy git config --global --unset http.proxy (unset proxy) git config --global http.proxy 192.168.1.1:8083 (set proxy)
-
Initialization warehouse
git init
-
Viewing File Status
git status
submit
-
Add files to the staging area (Indicates all files in the current directory also support a single file)
git add .
-
The revocation of the specified file from scratch
git reset HEAD file
-
Discard changes to the specified file workspace
git checkout -- file
-
Will be submitted to a local file repository in the temporary area
git commit -m "comment"
-
Pull remote file
git pull origin
-
The local commits push remote
git push origin
help
-
git help
-
View using the help of a command
git help add
-
View git Guide (this command will show in detail the life cycle of Git)
git help tutorial
Branch Management
1, view all remote branch
git branch -r
-
View all branches
git branch -a
-
Switching branch
git checkout local_branch_name
-
Create a local branch from a remote branch and switch to the branch
git checkout -b local_branch_name origin/remote_balance_name
-
Delete the local branch
git branch -D local_branch_name
-
Delete remote branch
git push origin --delete remote_branch_name
-
Rename the local branch name
git branch -m old_branch_name new_branch_name
View submit records
-
View Log
git log
-
View Log (display formatting)
git log --pretty=oneline
Merge code
-
Merging a branch code
git merge --no--ff branch_name
There are many Git commands, which vary in the same command parameters will behave differently. We can see its detailed usage by helping.
Related Reading:
" Git version management of the practice team ."
" Talk about MySQL privilege "
" Git common commands and common mistakes ."
Scan code concerned, together with progress
Personal blog: http://www.andyqian.com