How do I use git-tfs and idiomatic git branching against a TFS repository?

前端 未结 3 750
天涯浪人
天涯浪人 2020-12-07 16:27

How Do I Use git-tfs Idiomatically?

  • The git idiom is to check out branches to the root directory of the repository. Checking out a branch will re

3条回答
  •  情深已故
    2020-12-07 17:25

    Here's one way you can do this, and still maintain some relationships between master and the branches. You'd probably want to script it. Excuse me if I use bash statements rather than windows command line for some of my examples

    First clone the whole repository out, as in your first example, with branches as directories.

    This moves the trunk to the root. (hopefully there are no conflicts with your branch folders)

    mv trunk/*.* .
    

    Commit your new master

    git commit -a -m "refactoring master"
    

    creating a new branch

    git checkout -b feature-login
    

    Copy the branch files over the root files

    mv feature-login/*.* .
    

    Don't need these here any longer

    rm -rf [all_branch_directories]
    

    Commit the branch

    git commit -a -m "refactoring feature-login"
    

    back to master

    git checkout master
    

    Do it all again

    git checkout -b next_branch
    

    etc. etc..

    Finally at the end

    git checkout master
    rm -rf [all_branch_directories]
    git commit -a -m "refactoring master"
    

    It's not perfect, but you end up with all your branches cloned off master and diffed more or less appropriately. AFAIK git should be fine if you overwrite a file with another file but the contents don't change, which allows this to all work.

    One downside is that you won't clear out any files in the branches that have been deleted from the trunk. This may or may not be an issue for you...

提交回复
热议问题