Some notes on GIT operations

Source: Internet
Author: User

Here are some of the things you should be aware of when learning about Git, which are small details where there may be errors, and I hope you can point it out . 1.git use, after installation, first to open git bash 2. You must log in before you can manipulate git commands 3. Use git init to install a git repository that stores files that need to be managed.  git commands such as 4.git status, can only be used in git repositories 5.git Reset--hard head^ (HEAD ~100) back to the previous version, Git reset--hard 232233 (git version number before several) can go back to the new versiongit switch version is only the pointer head to the corresponding version, not delete the new version of the file, so just remember the latest version of the version number absolutely no problem back to the new version of thegit reflog can log every operation log, you can find the latest version of the Git ID 6.git Commit Command commits the version, the location of the commit version branch is related to the current head, if it is added on the previous branch, it will derive a new branch under the branch 7.git diff: Determine the difference between a file on a workspace (local environment) and a file in staging areagit diff HEAD-Readme.txt: Look at the difference between the current version in the workspace and the repository (note-there is a space between the Readme.txt) 8.git Checkout--File: Discard the modification of the workspace, if added to staging area, is restored to and staging area consistent, if submitted staging area no content, is restored to the current version of the same. If the local file is not submitted and not added to the staging area, it cannot be discarded.  9. Only the local git library, no remote library, with git RM filet Delete the submitted files, using git checkout-file is not able to recover files, if it is deleted at the time of staging area, you can first use git reset HEAD-file , and then use git checkout--fifle to restore to the local workspace. Add error when 10.push, first delete origin with Git remote RM origin, then reconnect, add GitHub username and password, then push to succeed. 11.git Merge Dev: merges the Dev branch to the current branch, and if there is a conflict (that is, two branches commit the modification) must resolve the conflict before you can cut back to the other branch 12. Changes to the content on the branch are not committed, and with git checkout master back to the main branch, the content on the main branch is synchronized to the content of the component. You need to use Git stash on the branch to save the branch workspace and then cut back to master, without affecting the main branch 13. Remove the remote tag, git push origin:refs/tags/<tagname>, and note that there are spaces before the colon 14.git config--list: can view all configuration information, git config--list |grep user.name: View user.name configuration information directly via git config--global User.Name XXX: You can modify the configuration information User.Name

Some notes on GIT operations

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.