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

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

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

21条回答
  •  难免孤独
    2020-11-22 09:07

    Here is the complete solution for pulling and pushing only a particular file inside git repository:

    1. First you need to clone git repository with a special hint –no checkout
    git clone --no-checkout 
    
    1. The next step is to get rid of unstaged files in the index with the command:
    git reset
    
    1. Now you are allowed to start pulling files you want to change with the command:
    git checkout origin/master 
    
    1. Now the repository folder contains files that you may start editing right away. After editing you need to execute plain and familar sequence of commands.
    git add 
    git commit -m 
    git push
    

提交回复
热议问题