Git命令干货

2020-07-27  本文已影响0人  英俊的风

下载:

git clone <serverUrl>
git clone -b <分支> <serverUrl>   #下载分支

提交:

git status    # 查看状态
git commit -m <注释>
git push origin <master或分支>    #提交

删除文件/文件夹:

git rm <文件名称>
git rm-r  <文件夹>/

回滚文件:

git log <filename>    # 查看指定文件的历史版本
git checkout <commitID> <filename>    # 回滚到指定commitID

回滚版本:
回滚到最近一次版本:
方式1:

git revert HEAD
git push origin <master或分支>

方式2:

git reset --hard HEAD^
git push origin <master或分支>-f

回滚到某次提交:
方式1:

git log  # 找到要回滚的commitID
git revert <commitID>
git push origin <master或分支>-f

方式2:

git log  # 找到要回滚的commitID
git reset --hard <commitID>
git push origin <master或分支>-f

删除某次提交:

git log --oneline -n5
git rebase -i   <commitID>^
git push origin <master或分支>-f
上一篇 下一篇

猜你喜欢

热点阅读