最近工作需要,在项目使用的过程中,整理了一些常用的git 命令,供大家借鉴参考。
重置git 密码 git config --global credential.helper store
**查看本地分支和追踪情况** git remote show origin git remote update
**本地分支跟远程同步** git remote update origin --prune git checkout -b dev(本地分支名) origin/dev(远程分支名)
**rebase命令** git fetch git pull -r 或者 git pull --rebase git rebase origin/master git status git add -am '备注' git rebase --continue git push
强制更新 git reset --hard origin/develop-1 git reset --hard 版本id
**merge命令** git checkout 需要合并的分支 git merge 需要合并到当前分支的分支
**add 全部** git add . git add --all
**查看远程分支** git branch -r
查看本地跟远程分支 git branch -a
**删除分支** git branch -d 分支 git push origin -delete 分支 git remote prune origin 删除远程已删除分支
**根据指定版本号创建分支** git checkout -b branchName commitId 方法一: git stash git checkout branch2 git stash pop 方法二: git stash git checkout branch2 git stash list #检查在不同分支中创建的各种存储 git stash apply x #选择正确的一个
将一条提交合并到当前分支
git cherry-pick commitid
将多条连续提交合并到当前分支
git cherry-pick commitd .. commitd
git reset --hard commid
git push -f origin branch