查看本地分支
git branch
查看所有分支
git branch -va
切换本地分支
git checkout xxx
切换远程分支
git checkout -b xxx remotes/origin/xxx
或git checkout -t remotes/origin/xxx
删除本地分支
git branch -d xxx
拉取远程更新并合并到当前分支
git pull
推送当前分支更新到远程
git push
回滚到历史提交:
git reset --hard <commit-id>
, 然后再git push -f
(commit-id是要回滚到的id,已经push的代码最好别用这种方式回滚)更好的回滚是使用
git revert <commit-id>
(commit-id是要放弃的提交)(当前commit,可以用HEAD),然后提交远程删除远程origin
git remote remove origin
更换远程地址:
git remote set-url origin xxx
暂存:
git stash
查看暂存列表:git stash list
恢复最近暂存:git stash apply
恢复指定暂存:git stash apply stash@{1}
本地创建分支并推送远程
git checkout -b xxx
git push origin xxx:xxx
合并远程分支
git merge remotes/origin/master
回滚查看历史代码
git reflog
git reset --hard xxx
打tag:
git tag xxx
,推送tag:git push origin xxx
登陆发表评论