git tfs: How to rcheckin git commits when there is another checkin in tfs?

青春壹個敷衍的年華 提交于 2019-12-22 13:06:55

问题


For a remote-worker without access to our TFS we cloned a TFS repository using git tfs. When we got back his repository we saw that he worked on a new feature branch.

Before trying to rcheckin his changes, we merged his feature branch into the master branch. Since he didn't commit anything to master, a fast forward took place, resulting in a single stream git log. Unfortunately, since the initial clone another (completely unrelated) checkin happened on TFS. When we try to rcheckin, we get the following error message:

Fetching changes from TFS to minimize possibility of late conflict...
error: New TFS changesets were found.
You may be able to resolve this problem.
- Try to rebase HEAD onto latest TFS checkin and repeat rcheckin or alternatively checkin s

I do not understand how the suggested rebase could help if we need all commits to reflect as checkins on TFS.

Is there any way to get all the git commits as individual TFS checkins in this situation?


回答1:


The answer of @Cupcake is good but I want to add some things...

If you want to be nearer than the tfs workflow when just checked in and solve your merge conflicts during this step, you could use:

git tfs rcheckin --quick --autorebase

which is equivalent to :

git tfs pull --rebase
git tfs rcheckin

It's not necessarily the better thing to do because, normally between the pull --rebase (where your changes and the one coming from tfs are 'merged') and the rcheckin (where you push your changes to tfs), you should at least build your solution and also run your unit tests.

But I recognized that sometimes it's a lot easier and my team (all old tfs users) only want to do that!

You should also be aware that's during the pull --rebase step that your changes are 'merged' with the ones of your team so that's where merged are done at the file level and like with tfs when you checked in, you will have to solve conflicts.

In the case of the rcheckin --quick --autorebase, if there is conflicts, the command will exit. You will have to solve them and lauch the command again.




回答2:


You can simply do what the plugin says and rebase the git repo's version of master, which contains the work of the remote-worker, on top of the new changes from TFS. The rebase will preserve the order of the original commits...though if there are conflicts, those will have to be resolved on the commits where the conflicts occur.

git tfs pull --rebase
git tfs rcheckin

You can also just use git tfs fetch and then use git's native rebase tools to do this, but that will involve more steps...the git-tfs command should take care of all of that for you.

Also, just in case, for some reason, the rebase ends up giving you a result that you don't want, put a temporary branch on the tip of master that you can hard reset to, if you need to:

git branch temp master
git tfs pull --rebase

# In case you don't like the rebase results:
git reset --hard temp

# Or if you like the results, check-in
git tfs rcheckin

Documentation for git-tfs pull.



来源:https://stackoverflow.com/questions/22921465/git-tfs-how-to-rcheckin-git-commits-when-there-is-another-checkin-in-tfs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!