git pull --rebase origin origin_branch
git checkout -b new_branch # 新建并切换分支
git checkout branch # 切换分支 git checkout - # 切换到上一次分支
git status
git add .
git commit -m 'message'
git log # 当前分支 git log --all # 全部分支 git log --oneline
git push origin origin_branch
git merge --no-ff branch
git checkout -- xxx # 某个文件 git checkout -f # 全部
git add . # 没有被 git 管理的文件,须要使用 git stash
stash
git stash list
git stash pop stash@{stash_id}
git stash
冲突git stash pop
冲突,不会自动删除git stash
中的记录需手动清理git
git stash drop stash@{stash_id}
git branch -d local_branch # 普通删除 git branch -D local_branch # 强制删除
git push --delete origin origin_branch
Tip:没法重命名远端分支,须要现删除远端分支,再将本地分支推到远端。bash
git push origin local_branch:origin_branch
git fetch git checkout origin_branch
git branch -m old_branch new_branch # 不在 old_branch git branch -m new_branch # 在 old_branch
git commit --amend -m 'message'
git
仓库开发者信息git config --global user.name git config --global user.email
git reset HEAD^1
git reset --hard commit_id
git merge --abort
git reflog
Tip:搭配回滚可御剑飞行fetch
git tag v1.2.3 # 当前版本打标签 git push origin --tags # 标签推到远端
git
远程关联git remote -v
git remote set-url --add origin origin_url
git remote add origin_name origin_url