Switch Git branch without files checkout

前端 未结 11 1441
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 15:36

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 swit

11条回答
  •  独厮守ぢ
    2020-11-29 16:28

    If you are simply trying to change where a remote branch points, you can do it with "git push" without touching your local copy.

    http://kernel.org/pub/software/scm/git/docs/git-push.html

    The format of a parameter is an optional plus +, followed by the source ref , followed by a colon :, followed by the destination ref . It is used to specify with what object the ref in the remote repository is to be updated.

    eg, to update foo to commit c5f7eba do the following:

    git push origin c5f7eba:foo
    

    Not sure if that's what you were after or not.

提交回复
热议问题