其他分享
首页 > 其他分享> > Git常用命令

Git常用命令

作者:互联网

记录一下工作中常用的git命令,不定期更新。

设置vim为git的默认编辑器

git config --global core.editor "vim"

克隆repo的特定branch

git clone -b branch-name repo.git

按照文件显示diff

git diff commit1 commit2 --stat

变基,一般用来合并多个commit

git rebase -i HEAD~4

撤销所有暂存的文件

git reset HEAD .

撤销某个暂存的文件

git reset HEAD -- filename

撤销某一次commit

git revert commit

暂时保存工作

git stash

使用某次暂存的代码

git stash apply stash@{1}

添加上游仓库

git remote add upstream repo.git

同步上游仓库的代码

git fetch upstream
git checkout master
git merge upstream/master

标签:HEAD,git,--,upstream,stash,repo,Git,常用命令
来源: https://www.cnblogs.com/littleorange/p/13468807.html