Git's birth and the common commands

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/u010695794/article/details/87997619

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

  1. 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"
  2. 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)
  3. Initialization warehouse

    git init
  4. Viewing File Status

    git status

submit

  1. Add files to the staging area (Indicates all files in the current directory also support a single file)

    git add .
  2. The revocation of the specified file from scratch

    git reset HEAD file
  3. Discard changes to the specified file workspace

    git checkout -- file
  4. Will be submitted to a local file repository in the temporary area

    git commit -m "comment"
  5. Pull remote file

    git pull origin
  6. The local commits push remote

    git push origin

help

  1. git help
  2. View using the help of a command

    git help add
  3. 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
  1. View all branches

    git branch -a
  2. Switching branch

    git checkout local_branch_name
  3. Create a local branch from a remote branch and switch to the branch

    git checkout -b local_branch_name origin/remote_balance_name
  4. Delete the local branch

    git branch -D local_branch_name
  5. Delete remote branch

    git push origin  --delete remote_branch_name
  6. Rename the local branch name

    git branch -m old_branch_name new_branch_name

View submit records

  1. View Log

    git log
  2. View Log (display formatting)

    git log --pretty=oneline

Merge code

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

" On the JPDA the Java "

" 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

 

Guess you like

Origin blog.csdn.net/u010695794/article/details/87997619