GIT multiple local checkouts

走远了吗. 提交于 2019-11-30 17:54:59

问题


I want to checkout multiple branches of the same git repostiory on the same Computer (Linux and Windows). However as the repository might be huge, I would prefer to have the repository once and only multiple working directories.

Is this possible? How so?


回答1:


It is possible since Git 2.5 and its git worktree command.

It replaces an older script contrib/workdir/git-new-workdir, with a more robust mechanism where those "linked" working trees are actually recorded in the main repo new $GIT_DIR/worktrees folder (so that work on any OS, including Windows).

Once you have cloned a repo (in a folder like /path/to/myrepo), you can add worktrees for different branches in different independent paths (/path/to/br1, /path/to/br2), while having those working trees linked to the main repo history (no need to use a --git-dir option anymore)

See "Multiple working directories with Git?"



来源:https://stackoverflow.com/questions/32043533/git-multiple-local-checkouts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!