Git: How to update/checkout a single file from remote origin master?

后端 未结 7 951
长发绾君心
长发绾君心 2020-12-12 08:41

The scenario:

  1. I make some changes in a single file locally and run git add, git commit and git push
  2. The file is
7条回答
  •  醉话见心
    2020-12-12 09:23

    It is possible to do (in the deployed repository)

    git fetch
    git checkout origin/master -- path/to/file
    

    The fetch will download all the recent changes, but it will not put it in your current checked out code (working area).

    The checkout will update the working tree with the particular file from the downloaded changes (origin/master).

    At least this works for me for those little small typo fixes, where it feels weird to create a branch etc just to change one word in a file.

提交回复
热议问题