0

What I successfully did until now:

  • git tfs clone from my Main branch in TFS.
  • push this repo to my bitbucket account.
  • created a branch locally (git checkout -b testbranch)
  • created the same branch on TFS (git tfs branch $/Repo/testbranch)
  • made some changes for test, and a commited on git only (git add, git commit on testbranch). Did not push them to bitbucket.

What is the problem now:

executed: git tfs rcheckin, and as result I got my changes checked in to my Main branch on TFS (I want to check in to testbranch)

tried: git tfs rcheckin -i testbranch, and got the following message: "No TFS parents found!"

Any idea on how to fix it?

Andrey
  • 461
  • 1
  • 6
  • 17
  • Is `testbranch` actually a TFS branch? It looks to me that you have created a local feature branch in your git clone and it may not exist in TFS. 'synch' is not a standard git terminology so it's not too clear what you mean when you state you 'synched' something. committed and pushed upstream? You can create feature branches from master in git and then do `git tfs rcheckin -i default` to commit that feature branch to TFS's main branch. Is that what you actually want? – patthoyts May 26 '15 at 19:08
  • I updated my question to make it clear. But what I want is: to push my git local changes to the TFS remote branch (testbranch, not the main branch). – Andrey May 26 '15 at 19:15

1 Answers1

0

The same answer that I did in the git-tfs forum but because you asked your question here also...

Any idea on how to fix it?

Don't know... But I know what you did wrong :-(

If you want to check in in a new tfs branch, you MUST create it before (and init it with git tfs branch --init) or create it with the command git tfs branch. And then you can work with it in git.

If you failed to do it at the beginning , you could do it before the rcheckin and doing a git rebase...

And now, you are able to rcheckin in the branch...

Git-tfs is able to find automatically the branch in which the check-in should be done by using the metadata stored in the last commit checked in tfs. In your case that was the one of the main branch!

Now, solving your problem.............

Because you can't delete a changeset with tfs it won't be an easy thing :-(

The easier solution is to create a new commit that revert all the changes and rcheckin it in tfs. After that, your master branch should be in the same state that before the check-in of the branch commits.

Then, create a git branch on the last changeset corresponding to the commit of the dev branch that you previously badly rcheckin. Create a tfs branch, like I said earlier (you should have a new commit with the good metadata git-tfs-id, look carefully at the TFS path!)

And use git rebase --onto -i to rebase the commits of the dev branch onto this new commit. Don't forget to remove ALL the metadata of all the commits that you will rebase (or you will end in the same mess again)!!

Now you could rcheckin in the TFS branch!

Philippe
  • 28,207
  • 6
  • 54
  • 78
  • tks for your help, but I created the branch using _git tfs branch_ (see my edit). I can recreate a branch from master and redo my changes, no problem with that. The correct way of doing this is using _git tfs branch_ with the branch checked out right? – Andrey May 27 '15 at 08:44