Revising git repo history to become linear

We need to generate a TFS repository from a Git source code base, we would like to preserve the original commit history, so I tried to use Tf-Git “git tf checkin –deep” command that is supposed to create a TFS changeset for each Git commit.

Unfortunately this step fails because a lot of commits in the Git repo have two parents due to merges, and TFS requires commit history to be linear to be able to import it. So I am getting the following error:

  • Is it possible to slim a .git repository without rewriting history?
  • Git checkout with libgit2
  • git upload the files as root
  • Connecting Aptana with Git
  • Does any faster centralized version control than SVN exists?
  • git add submodule hash directly
  • git-tf: cannot check in - commit 2b15822 has multiple parents, please rebase to form a linear history or use --shallow or --autosquash
    

    This is understandable. But what can be done about it if the existing Git repo has a long chain of such commits? I know it’s possible to spend a day or two revising commit history manually, but that’s not what we want to spend our days on. Do I understand correctly that there is no automated way of fixing commit history to become linear, so unless we want to spend many hours on manual work, we should just import the whole history as a single changeset?

  • npm install from private gitlab repository - authentication failed
  • Using git with a PHPFog Wordpress app
  • Using LibGit2Sharp to truncate GIT commit history
  • PHPUnit on pre-commit Git Hook seems to use different PHP version
  • How to revert a chunk of a file in the staging area?
  • Git Push Error - Could not resolve host name
  • One Solution collect form web for “Revising git repo history to become linear”

    A rebase should actually solve this for you.

    git rebase -i <hash of commit before first branch has been created>
    

    In the window that pops up when you execute that command, don’t change anything. Simply save and close.

    An illustration:

    A <- B <- E <-----F <- G      master
         ^            ^
          \          /
           - C <- D -             branch
    

    Commits C and D were on a branch and have been merged into master with the merge commit F.

    Now, executing git rebase -i B will yield the following result, when executed from master:

    A <- B <- C <- D <- E <- G    master
    

    Please note that the merge commit F disappeared, because it would be empty.

    Git Baby is a git and github fan, let's start git clone.