美文网首页
git常用命令

git常用命令

作者: super_2e20 | 来源:发表于2019-05-16 10:45 被阅读0次

一.git合并两个远程分支 (现在是想把远程master合并到远程develop分支上)

1.先检出项目到一个文件夹

git clone

2.打开终端切换到文件路径下

cd path

3.检出项目默认的是master分支,现在查看全部远程分支

git branch -a

 * master
 remotes/origin/HEAD -> origin/master
 remotes/origin/develop
 remotes/origin/master
4.切换分支
*master合并到develop分支上

git checkout master
git checkout develop

git merge master

(1).如果没有报错就直接提交代码

git push develop

(2).如果报错 基本冲突了:
 CONFLICT (content): Merge conflict in      app/src/main/AndroidManifest.xml
Auto-merging app/build.gradle
CONFLICT (content): Merge conflict in app/build.gradle
Automatic merge failed; fix conflicts and then commit the result.

然后把冲突的文件git add,和commit
,比如你有2个冲突文件,多文件add的时候直接空格隔开

git add app/src/main/AndroidManifest.xml app/build.gradle

最后再commit

git commit -m "解决2个分支之间的冲突"
5.提交代码

git push origin develop

Git鼓励大量使用分支:
查看分支:git branch
创建分支:git branch <name>
切换分支:git checkout <name>
创建+切换分支:git checkout -b <name>
合并某分支到当前分支:git merge <name>
删除分支:git branch -d <name>


git add -A 提交所有变化

git add -u 提交被修改(modified)和被删除(deleted)文件,不包括新文件(new)

git add . 提交新文件(new)和被修改(modified)文件,不包括被删除(deleted)文件

提示 在提交代码时如出现:warning: refname 'branchName' is ambiguous

****修改远程分支名称

 git branch -m <originBranchName> <newBranchName>
 git push origin <newBranchName>

相关文章

网友评论

      本文标题:git常用命令

      本文链接:https://www.haomeiwen.com/subject/bsgloqtx.html