Git commonly used commands
git config --list
Displays the current configuration Gitgit config --global user.name "你的名字"
Let all your Git repository bind your namegit config --global user.email "你的邮箱"
Let all your Git repository bind your mailboxgit init [project-name]
Initialize your warehouse, to bring the project name will be initialized to a new git repository and directorygit add .
All the documents submitted to the work area to the staging areagit add ./<file>/
The workspaceDocuments submitted to the staging area git commit -m "xxx"
All documents submitted to the staging area of the warehouse district, empty staging areagit remote add origin https://github.com/name/name_cangku.git
Local and remote warehouse to warehouse connectgit push -u origin master
The main branch master warehouse district to submit to a remote warehousegit push -u origin <其他分支>
The other branch submitted to the remote repositorygit status
View the current state of the repositorygit diff
View file modification of specific contentgit log
Display furthest from the most recent commit history togit clone + 仓库地址
Download clone filegit reset --hard + 版本号 回溯版本
, Version number commit the time to follow together with the mastergit reflog
Display the command historygit checkout -- <file>
Undo command, replace the file with a workspace file in the repository. I feel like the Git world ctrl + zgit rm
Delete the file repositorygit rm [file1] [file2] ...
Delete a workspace file and delete into the staging areagit rm --cached [file]
Stop following the specified file, but the file will be retained in the workspacegit mv [file-original] [file-renamed]
Rename files, and will be renamed into the staging areagit branch -a
View all current branch (local and remote branch)git branch <分支名字>
Creating a branchgit branch --track [branch] [remote-branch]
Create a new branch, a tracking relationship with remote branches specifiedgit branch --set-upstream [branch] [remote-branch]
Create a tracking relationship between the existing branch and remote branches specifiedgit checkout <分支名字>
Switch to the specified branch, and updates the workspacegit checkout -
Switch to a branchgit merge <分支名字>
Merge branchgit branch -d <分支名字>
Delete branch, there may delete fail because Git will not be merged protection branchgit branch -D + <分支名字>
Forcibly removed, discarded not be merged branchgit log --graph
View branch merged graphgit merge --no-ff <分支名字>
When merging branches disable Fast forward mode, this mode will be lost because the branch history informationgit stash
When there are other tasks beeped, the current work site "store" up and continue to work after after recoverygit stash list
You just see the "store" where up to go to workgit stash apply
Not recover deleted stash contentgit stash drop
Delete stash contentgit stash pop
While restoring the contents of the stash is also deletedgit remote
View remote database information displayed origin, the default name for the remote repository origingit remote -v
Display more detailed informationgit pull
The latest submission to crawl down from a remote repository, merge locally, and git push the oppositegit push [remote] --force
Forced to push the specified remote branch even if there is a conflictgit rebase
The bifurcation commit history "finishing" in a straight line, it looks more intuitivegit tag
View all tags, you can know the history version of taggit tag <name>
Playing tag, the default is HEAD. For example, git tag v1.0git tag <tagName> <版本号>
把版本号打上标签,版本号就是commit时,跟在旁边的一串字母数字git tag -d [tagName]
删除本地taggit push origin :refs/tags/[tagName]
删除远程taggit show <tagName>
查看标签信息git tag -a <tagName> -m "<说明>"
创建带说明的标签。 -a指定标签名,-m指定说明文字git push origin <tagname>
推送某个标签到远程git push origin --tags
一次性推送全部尚未推送到远程的本地标签git push origin :refs/tags/<tagname>
删除远程标签git config --global color.ui true
让Git显示颜色,会让命令输出看起来更醒目git add -f <file>
强制提交已忽略的的文件git check-ignore -v <file>
检查为什么Git会忽略该文件git diff
显示暂存区和工作区的差异git fetch [remote]
下载远程仓库的所有变动git archive
生成一个可供发布的压缩包
小确幸
每一丝灵感都值得被记录,每一笔记录都是成长,每一点成长都值得欢呼
博主个人站: www.imisty.cn
CSDN博客: https://blog.csdn.net/lookinthefog
博客园 :https://imist.cnblogs.com/
希望能够认识一些热爱技术的小伙伴,欢迎友链接哟