Common commands for Git

Source: Internet
Author: User

git add filename
Git add-a This is to add all the modified or added files to the Repository (library)

git commit-m ' message '


Git checkout-b feature create and switch branches

To add a remote library:

To associate a remote library, use the command git remote add origin [email protected]:path/repo-name.git ;

Once associated, use the command to git push -u origin master push all the contents of the master branch for the first time;

Thereafter, after each local commit, you can use the command to push the git push origin master latest changes whenever necessary


Git push Origin dev pushes the local branch to the remote branch dev


Git show hash file name see Recent changes to this file name

Git whatchanged View Recent Changes

如果是只用add 把文件提交到版本库中,那用下面的命令解决

git reset HEAD

或用 git rm --cached filename

如果你的文件add后,还commit到版本库中,那用下面命令

git rm 会把一个不想要的文件删除掉。再commit 后就会取消文件

git reset --hard HEAD^

当然往上100个版本写100个^比较容易数不过来,所以写成HEAD~100

git branch -d feature-vulcan    删除本地的分支

git branch -D feature-vulcan    强行删除分支



git reset--hard head^
Of course up to 100 versions write 100 ^ more easy to count, so write head~100

git remote-v viewing remote branch information

Common commands for Git

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.