How to sparsely checkout only one single file from a git repository?

前端 未结 21 1893
Happy的楠姐
Happy的楠姐 2020-11-22 08:14

How do I checkout just one file from a git repo?

21条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 09:09

    In git you do not 'checkout' files before you update them - it seems like this is what you are after.

    Many systems like clearcase, csv and so on require you to 'checkout' a file before you can make changes to it. Git does not require this. You clone a repository and then make changes in your local copy of repository.

    Once you updated files you can do:

    git status
    

    To see what files have been modified. You add the ones you want to commit to index first with (index is like a list to be checked in):

    git add .
    

    or

    git add blah.c
    

    Then do git status will show you which files were modified and which are in index ready to be commited or checked in.

    To commit files to your copy of repository do:

    git commit -a -m "commit message here"
    

    See git website for links to manuals and guides.

提交回复
热议问题