git bash操作指令
克隆项目指定分支:
# <branchname> 分支名,<remote-repo-url> 远程仓库url
git clone --branch <branchname> <remote-repo-url>
或
git clone -b <branchname> <remote-repo-url>
查看项目仓库的分支列表
# 进入项目目录中
git branch -a
将本地指定分支跟 设置踪到远程指定分支
# 切换到个人的本地指定分支local-branch-name
git checkout local-branch-name
# 设置跟踪远程的指定分支branch-name
git branch -u origin/branch-name
本地代码已经变动,但需要拉去远程代码,又暂时不想提交代码:
# 1、先将本地代码放入暂存区
git stash
# 2、拉取到远程代码
git pull
# 2.1 若出现未拉取成功, 可查看是否存在类似如下警告
# 原因:本地代码与远程代码可能存在冲突
Auto-merging routers/backend_supplier/delivery.py
CONFLICT (content): Merge conflict in routers/backend_supplier/delivery.py
Auto-merging routers/backend_supplier/order.py
CONFLICT (content): Merge conflict in routers/backend_supplier/order.py
error: could not apply 2201698... 提交信息
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply 2201698... 提交信息
# 2.2、通过git rebase 指令进行合并(此时可能存在内容冲突,须手动解决冲突问题)
git rebase origin/develop
# 2.3、处理冲突后即可继续提交代码,查看状态
git status
# 3、将暂存区的代码合并进来,这样自己的代码就还是未提交状态
git stash pop
# 4、添加变动文件
git add .
# 5、编辑完个人代码后,再提交
git commit -m "指定提交的信息"
# 6、推送本地代码到远程默认分支
git push