Pregunta

When git tfs could not create a merge commit, it says warning: this changeset 7504 is a merge changeset. But it can't have been managed accordingly because one of the parent changeset 7494 is not present in the repository! If you want to do it, fetch the branch containing this changeset before retrying...

As per the documentation, Note: if you see a warning, you could correct that by reseting the tfs remote to a previous commit. Then fetch the merged branch and retry to fetch the branch.

Can anyone please elaborate on reseting the tfs remote to a previous commit. Though, I've now fetched the merged branch, I don't understand how do I reset it to previous commit to the failed one. I'm not sure but do I have to git checkout <hash of the previous commit>?

¿Fue útil?

Solución

Yes, now git-tfs try to create merge commit when it encounter merge changesets (now that it has a satisfying branch support).

This message is just a warning message and when you see it, you have 2 options...

  • The first one is to do nothing because you know that it was, for exemple, an old feature branch that you will never work on that and MORE IMPORTANT that in the future you will never merge again in your parent branch.

  • The second one is if you really want to have this merge commit. Because you want a good history or MORE IMPORTANT because you still work on this branch and will have to merge it in the parent branch.

To do that, you will have to reset your tfs remote (because in fact the commit has already been created --to keep compatibility with how git-tfs works in previous version and for those that can't work with branches--).

To reset your remote, you must use reset-remote command.

Then intitialized the branch that is merged in the parent branch with branch --init.

Reset also the local branch to the tfs remote (due to an internal git-tfs optimization).

And fetch again the parent branch. Now that the merged branch exist and is fetch, git-tfs will find the parent changeset from the merged branch and you will have a beautiful merge commit in your git repository ;)

So, If you did this earlier

git tfs clone https://CompanyName.visualstudio.com/DefaultCollection "$/CompanyName/Main" KfGitMain --workspace="C:\TFS\Main"
cd GitMain
git tfs branch --init "$/CompanyName/Release/20140121.1" live20140121.1
git tfs branch --init "$/CompanyName/Release/20140121.1-hotfix" hotfix20140121.1

and if you received the warning for all the three due to code merges to and from each other, so you will have to

git checkout hotfix
git tfs reset-remote 5fb83335b8dfc6fbb96e0a54a48dc06c506e3277 ## previous commit of the first failed commit
git reset --hard tfs/hotfix
git tfs pull -i hotfix

git checkout live
git tfs reset-remote eba62a1446f3f81676d051336ca254fe54c37d74
git reset --hard tfs/live
git tfs pull -i live

git checkout master
git tfs reset-remote 72727737ec52f9b96d22d343770186a342c8b166
git reset --hard tfs/default
git tfs pull -i default

Note: if you don't have too many branches and/or strange tfs history, all that could be avoided using git clone with the option --with-branches that will init and fetch all the branches taking care of the merge changesets

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top