分别有仓库 A(github),B(JAE 的 git),本机为C。
A, B都进行了 README.md 的初始化,就是说,这个情况下,已经存在冲突了,log不一致。
先从仓库A获取下来,C 修改完毕提交,顺利提交至A,
此时 如何从 C 提交到B,需要进行多少操作,使得仓库记录 A 和 B 的log一致(后面一致即可)?
这个问题我尝试过,没解决。
某草草2017-04-27 09:04:42
After so long, after continuous use of git, I also know the specific method.
Assume that warehouse a is the final use warehouse and b is the release warehouse. The branches are all dev
Now I will reply to myself:
The first step is to add a remote warehouse
git remote add origin1 git.a
git remote add origin2 git.b
The second step is to ensure that there is nothing changed locally, pull the remote warehouse address, and then rebase.
git fetch origin1
git rebase -i origin1/dev
If there is a conflict, resolve it.
git push -f origin1 dev
git push -f origin2 dev
done.
漂亮男人2017-04-27 09:04:42
In fact, you can clear the initialization files and add the address of another remote warehouse to the local .git/config, such as:
[remote "all"]
url = https://github.com/segment/test.git
url = https://git.oschina.net/segment/test.git
The subsequent operations are the same. Submitting the code will be submitted to the two warehouses simultaneously.
阿神2017-04-27 09:04:42
I haven’t tried the situation of two git repositories. My guess is this:
1.git remote add $C remote warehouse name $C remote warehouse url
2.fetch to C
3. Local merge
4.push $C remote warehouse name $project name
Reference: http://www.git-scm.com/book/zh/Git-%E5%9F%BA%E7%A1%80-%E8%BF%9C%E7%A8%8B%E4%BB %93%E5%BA%93%E7%9A%84%E4%BD%BF%E7%94%A8
漂亮男人2017-04-27 09:04:42
The solution to keep all logs of a branch (assumed to be the master branch) the same:
After pushing it up, the logs of C and B will be consistent, and you can continue the operation after that
If you want to keep all branches consistent, I suggest you simply create a new project on jae and push C up
Hope it helps you
伊谢尔伦2017-04-27 09:04:42
I guess, before pulling from any remote repository, first
git stash
Then pull, modify, add, submit, push. Again
git stash pop
Then resolve conflicts if there are any. If there are no conflicts, directly pull the code from another remote warehouse, and then modify, add, submit, and push step by step.
It's all based on guessing. Please practice it yourself if you are specific. for reference only.
天蓬老师2017-04-27 09:04:42
I think you already know how to add multiple remote repositories, so I won’t go into that.
Straightforward: When C=A, under C git push -f 'B远程仓库' '分支'
In this way, although B will conflict with A C, it will be forced to overwrite the state of C. So A=B=C. The LOG will be consistent after that. The -f parameter means forced push.
just try it
我想大声告诉你2017-04-27 09:04:42
Just configure the mirror warehouse
1.git remote add --mirror=push --mirror=fetch repoName url
2.git push repoName master