Git Common operations commands

Source: Internet
Author: User

After the automatic change to the new department, every nine o'clock in the evening to 10 hours of normal work, and not much time to do the finishing. Although there are many things, less free time, but this is not a pretext to summarize. Don't say much nonsense, start with a simple one! About the git command principle related to the introduction of a large number of online, here just to organize their usual work in the most of the commands used to do notes.

1. New Branch

Create a new branch and switch to a new branch

git checkout-b hotfix_newbranch_20150417push local branch to remote git push-u origin hotfix_newbranch_20150417

Switch to the specified branch

git checkout develop_new

2. Add and submit

Add code to Staging Area (index)

git add *

Commits the code to the HEAD of the local repository but has not yet been committed to the remote repository

Git commit-m " Memo code submission Information "

3. Push changes to remote

Pushing code to a remote repository

git push Origin hotfix_newbranch_20150417 (will be pushed to the far end of the current branch if the branch number is not filled in later)

4. Delete a branch

Delete local Branch

git branch-d hotfix_newbranch_20150417

To delete a remote branch (where there is no local branch)

git branch-r-D origin/hotfix_20150320

git push Origin :hotfix_20150320

Delete Remote Branch (if local branch is already in progress)

git push origin--delete feature_appactivity_20150423

5. Merging and updating

Branch Update

Git pull

Merging branches

For example, if you want to merge a branch (develop) in development into a stable branch (master)

First switch the Master branch:git checkout master

Then perform the merge operation:git merge origin/develop or git merge origin/develop -x renormalize

If there is a merge conflict, resolve the conflict and execute git Add. Then execute git push origin develop_new commit to the far end.

6. Replace local changes

Replace the specified file in your working directory with the latest content in the HEAD

git checkout-- <file>

If you want to discard all your local changes and commits, you can get the latest version history on the server and point your landlord branch to it:

Git fetch origin

git reset--hard origin/master

Branch fallback to the specified commit version, 0c509beee4a8fc3f14a90cf4b commit ID for code submission

git reset--hard 0c509beee4a8fc3f14a90cf4b

Git push-f

7. Other

View the status of the current branch at any time

git status

Git commit record

git log

Built-in graphical git

Git gitk

Reference Link: http://rogerdudler.github.io/git-guide/index.zh.html

http://www.kancloud.cn/kancloud/igit/46729

Git Common operations commands

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.