开发者

switch branches without checkout in GIT

Here are the steps that I have followed:

  1. Created a repository
  2. added a file to the master branch.
  3. created a branch called test_branch.
  4. added close to 30k files in the test_branch & committed.
  5. now when I try to switch to master branch. It says "checking out files: 83% (24967/30002)", and now I have all the files which I have committed in test_branch in my master branch as well.

Why I am getting this e开发者_运维百科rror, and how to overcome it ?


  1. created a branch called test_branch

How did you make it? Have you checked if you have checked it out? There are two commands to do it - git branch will NOT checkout it and git checkout -b will.


For such large volume of files in one branch, as opposed to the other, it might be better to clone the repository (which should reference by default the master branch), while leaving your first repo on the test_branch.


If you want to keep the working dir unchanged, use git reset --soft <tree-ish>. To make branches point wherever you want without having to check them out, use git update-ref refs/heads/branch_name <tree-ish> where tree-ish could be head^, master^2~3, other_branch, other_branch@{"2 days ago"}, etc.

Hope this helps.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜