切换没有文件签出的git分支 [英] switch git branch without files checkout

查看:164
本文介绍了切换没有文件签出的git分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

git可以在不检出所有文件的情况下切换到另一个分支吗?切换分支后,我需要删除所有文件,重新生成它们,提交并切换回来。因此检出文件只是浪费时间(并且大约有14000个文件 - 这是一个长时间的操作)。



清除所有内容:



我需要所有这些才能将文档上传到github。 p>

我有gh-pages分支的回购。当我在本地重建文档时,我将它复制到repo目录,提交并推送到github。但我并不开心,因为我在本地有两份文件。我决定创建空的分支,并在提交后清空并删除文件。但切换是一个很长的操作 - 所以我问了这个问题。



我知道我可以留在gh-pages分支并删除文件,但我没有像肮脏的工作树)

解决方案

是的,您可以做到这一点。

  git symbolic-ref HEAD refs / heads / otherbranch 

如果你需要在这个分支上提交,你需要重置索引,否则你最终会根据最后一个签出的分支提交一些内容。

  git reset 


Is it possible in git to switch to another branch without checking out all files? After switching branch I need to delete all files, regenerate them, commit and switch back. So checking out files is just a waste of times (and there are about 14000 files - it is a long operation).

To make everything clear:

I need all this to upload documentation to github.

I have repo with gh-pages branch. When I rebuild documentation locally, I copy it to repo directory, commit and push to github. But I was not happy because I had two copies of documentation locally. And I decided to creaty empty branch and after commiting switch to empty and delete files. But switching back is a long operation - so I asked this question.

I know that I can just leave on gh-pages branch and delete files, but I don't like dirty working trees )

解决方案

Yes, you can do this.

git symbolic-ref HEAD refs/heads/otherbranch

If you need to commit on this branch, you'll want to reset the index too otherwise you'll end up committing something based on the last checked out branch.

git reset

这篇关于切换没有文件签出的git分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆