GIT-related knowledge

Source: Internet
Author: User

Some useful links:

https://www.git-scm.com/

http://nvie.com/posts/a-successful-git-branching-model/

git development mode:

It is recommended to have at least one master and develop branch. Master only makes version maintenance work, develop for development. The development is complete and the test is passed and merged into master.

Common scenarios:

    • Revoke commit to Remote

If you push the commit to remote without being pushed by someone else, you can use

git reset--hard <commit-hash>
Git push-f origin Master (assuming that both local and remote are operating on master)

To revoke the commit that was committed before.

But if someone else synchronizes your push, you can use revert locally to restore the commit you committed, then generate a new commit and push it to the far end.

Note: If the commit of remote is not irrevocable, you can choose to continue developing and pushing the updated commit in a way similar to fixing the bug.

    • Remove unwanted branches from remote

Git push origin: <delete branch>

    • Local rollback

Main commands: git revert and git reset

Git revert is to generate a new commit to undo a commit, the commit will be preserved, and the revert operation itself will be recorded.
Git reset is going back to a commit, commit and previous commit will be retained, but the subsequent changes will be returned to staging area (as appropriate). The operation itself is not logged.

--soft only commit is rolled back, index and content unchanged

--mixed commit and index are rolled back, content is unchanged

--hard commit and index are rolled back, content is reset and content cannot be retrieved

Possible problems:

    • Git status/add Chinese garbled

Scene:

When you use git add to add a file or use Git status to view the status, the Chinese file name will display garbled characters such as 274\232\350\256\256\346\200\273\347\273\223.png
Solution:
git config--global core.quotepath false

Reference Link: http://zengrong.net/post/1249.htm

    • Adding a new SSH key to the Ssh-agent

Reference Link: https://help.github.com/articles/adding-a-new-ssh-key-to-the-ssh-agent

GIT-related knowledge

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.