Common git commands summarized

Git commonly used commands

git tutorials on cloud code

  • git config --list Displays the current configuration Git
  • git config --global user.name "你的名字"Let all your Git repository bind your name
  • git config --global user.email "你的邮箱"Let all your Git repository bind your mailbox
  • git init [project-name]Initialize your warehouse, to bring the project name will be initialized to a new git repository and directory
  • git add .All the documents submitted to the work area to the staging area
  • git add ./<file>/ The workspace Documents submitted to the staging area
  • git commit -m "xxx"All documents submitted to the staging area of ​​the warehouse district, empty staging area
  • git remote add origin https://github.com/name/name_cangku.gitLocal and remote warehouse to warehouse connect
  • git push -u origin master The main branch master warehouse district to submit to a remote warehouse
  • git push -u origin <其他分支>The other branch submitted to the remote repository
  • git statusView the current state of the repository
  • git diff View file modification of specific content
  • git logDisplay furthest from the most recent commit history to
  • git clone + 仓库地址Download clone file
  • git reset --hard + 版本号 回溯版本, Version number commit the time to follow together with the master
  • git reflogDisplay the command history
  • git checkout -- <file>Undo command, replace the file with a workspace file in the repository. I feel like the Git world ctrl + z
  • git rmDelete the file repository
  • git rm [file1] [file2] ...Delete a workspace file and delete into the staging area
  • git rm --cached [file] Stop following the specified file, but the file will be retained in the workspace
  • git mv [file-original] [file-renamed]Rename files, and will be renamed into the staging area
  • git branch -aView all current branch (local and remote branch)
  • git branch <分支名字> Creating a branch
  • git branch --track [branch] [remote-branch] Create a new branch, a tracking relationship with remote branches specified
  • git branch --set-upstream [branch] [remote-branch]Create a tracking relationship between the existing branch and remote branches specified
  • git checkout <分支名字>Switch to the specified branch, and updates the workspace
  • git checkout - Switch to a branch
  • git merge <分支名字>Merge branch
  • git branch -d <分支名字>Delete branch, there may delete fail because Git will not be merged protection branch
  • git branch -D + <分支名字> Forcibly removed, discarded not be merged branch
  • git log --graphView branch merged graph
  • git merge --no-ff <分支名字> When merging branches disable Fast forward mode, this mode will be lost because the branch history information
  • git stashWhen there are other tasks beeped, the current work site "store" up and continue to work after after recovery
  • git stash listYou just see the "store" where up to go to work
  • git stash applyNot recover deleted stash content
  • git stash dropDelete stash content
  • git stash popWhile restoring the contents of the stash is also deleted
  • git remoteView remote database information displayed origin, the default name for the remote repository origin
  • git remote -vDisplay more detailed information
  • git pull The latest submission to crawl down from a remote repository, merge locally, and git push the opposite
  • git push [remote] --force Forced to push the specified remote branch even if there is a conflict
  • git rebase The bifurcation commit history "finishing" in a straight line, it looks more intuitive
  • git tag View all tags, you can know the history version of tag
  • git tag <name>Playing tag, the default is HEAD. For example, git tag v1.0
  • git tag <tagName> <版本号> 把版本号打上标签,版本号就是commit时,跟在旁边的一串字母数字
  • git tag -d [tagName]删除本地tag
  • git push origin :refs/tags/[tagName]删除远程tag
  • git 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/

希望能够认识一些热爱技术的小伙伴,欢迎友链接哟

Guess you like

Origin www.cnblogs.com/imist/p/11417588.html
Recommended