开发者

How to get a copy of a directory from another git branch in a transparent way?

How can a directory be copied from a git branch to another without git tracking the files?

My goal is to have different branches for a project and be able to import part of each branch to a single directory for packaging ? Each branch contains code for a specific version of Python, but the package must contain the code for all the Python versions, so the code from all version-specific branches must be copied into the master branch before packaging.

Here is an example:

  • The git-controlled, master-branch directory contains:

    uncertainties/
    
  • I want to import the version of uncertainties/ contained in the python-pre-2.5 branch, so that the 开发者_Python百科final directories are:

    uncertainties/  # Should not be touched
    uncertainties-py23/  # Imported from the python-pre-2.5 branch
    
  • A crucial point is that I do not want git status to report any change (if there was no change in the first place). In other words, the directory import process should be invisible to git.

By using git checkout python-pre-2.5 -- uncertainties and various combinations of renames (mv and git mv), I did not succeed in satisfying this last "git transparency" requirement. How can this be achieved?


Just put uncertainties-py23/ in .gitignore.


From master,

git archive python-pre-2.5 uncertanties > uncertanties-py23.tar
mkdir uncertainties-py23
tar xf uncertanties-py23.tar --strip-components=1 -C uncertanties-py23

And then add uncertanties-*/ or similar to your .gitignore.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜