Git 操作笔记

1. 更改本地用户名和邮箱

git config --global user.name "Your_username"
git config --global user.email "Your_email"

2. 回退操作

git reset --hard <版本号>
git push origin  HEAD --force
git revert 进行一次与上次commit相反的操作

3. 切换分支

git checkout [分支名 / hash值 / HEAD^]
git branch -f [branch name] HEAD~[number] 前移几步

4. 拿取其他commit

git cherry-pick [hash]

 5. 本地不commit暂存更改,还原分支

git stash
git stash pop 弹出

 6. 删除远程分支

# 方法1 删除命令
$ git push origin --delete <branchName>

# 方法2 推送空分支到远程分支
# git push origin :<branchName>

 7. 删除本地分支

git branch -d <branchname>

 8. 重命名本地分支

git branch -m <old branch> <new branch>

推送远程
git push origin <new branch>

 

posted @ 2019-04-16 11:06  森淼clover  阅读(131)  评论(0)    收藏  举报