查看本地分支
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 xxxgit push origin xxx:xxx合并远程分支
git merge remotes/origin/master回滚查看历史代码
git refloggit reset --hard xxx打tag:
git tag xxx,推送tag:git push origin xxx
登陆发表评论