Common commands for Git (i)

Source: Internet
Author: User

  1. Git configuration:

    git config--global user.name "Tina Gao"

    git config--global user.email "[Email protected]"

    After executing the above command, a. gitconfig file will be created in the home directory to view the contents: Cat ~/.gitconfig

  2. Clone a repository: Git clone http: ....

  3. To initialize a new repository:

    mkdir Project

    CD Project

    Git init

  4. To create a file:

    Touch file1 file2 File3

    echo "Test" >> file1

    echo "Test" >> file2

    echo "Test" >> file3

  5. To view the status of the current git repository:

    git status

  6. Add the untracked file to the buffer using the git add command:

    git add file1 file2 file3

  7. See which files in the cache are modified (diff comparison content):

    git diff--cached

  8. Submit to local repository: Git commit-m "Add 3 Files"

  9. To synchronize the local warehouse to the remote server:

    Git push Origin Master

  10. A git repository can maintain many branches and create branches:

    Git branch A

  11. View the current branch: Git branch

  12. Switch to branch: git checkout Master

  13. After making modifications on branch A, merge to master:

    git checkout Master

    git merge-m ' Merge a branch ' a

  14. Two branches when you change the same file, there is a conflict in the merge that causes the failure.

  15. Undo Merge: Git reset--hard head^

  16. View logs: Git log

  17. Log statistics (print detailed commit records): Git log--stat

  18. Format log as required: git log--pretty=short or git log--graph--pretty=oneline

  19. Log sort: git log--pretty=format: '%h:%s '--topo-order--graph

Common commands for Git (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.