git 常用指令大全

版权声明:本文为博主原创文章,未经允许不得转载。 https://blog.csdn.net/qq_37592252/article/details/84987838

创建本地库:git init

查看当前状态:git status

添加至缓冲区:git add <file name>

上传:git commit -m "xxx"

上传至远程库:git push origin master

未add前,撤销:git checkout -- <filename>

add后,撤销:git reset HEAD <filename>,随后git checkout -- <filename>

把误删的文件恢复到最新版本:git checkout -- test.txt

版本回退:git checkout -- test.txt

查看提交历史:git log

查看命令历史:git reflog

查看分支:git branch

创建分支:git branch <name>

切换分支:git chechout <name>

创建+切换分支:git checkout -b <name>

合并某分支到当前分支:git merge <name> (删除分支后不会丢掉分支信息 git merge --no-ff -m <name>

删除分支:git branch -d <name>

强行删除分支:git branch -D <name>

查看分支合并图:git log --graph

保存当前工作现场:git stash

恢复原先工作现场:git stash apply

删除工作现场:git stash drop

查看历史工作现场:git stash list

恢复并删除工作现场:git stash pop

查看远程库信息:git remote -v

多人合作

Created with Raphaël 2.2.0 Start git push origin <branch-name> if succeed? End git pull if "no tracking information"? git branch --set-upstream-to <branch-name> origin/<branch-name> yes no yes no

猜你喜欢

转载自blog.csdn.net/qq_37592252/article/details/84987838