How do I pull missing file back into my branch

前端 未结 4 1322
甜味超标
甜味超标 2021-02-01 14:01

I have cloned git project into local git repository. Then I have done something nasty to one of the files and in that panic I deleted file physically from drive (rm style.

相关标签:
4条回答
  • 2021-02-01 14:06

    If you want to restore all the missing files from the local repository

    git checkout .
    

    Warning: This method also restores all changed files and drops all the changes

    0 讨论(0)
  • 2021-02-01 14:12

    Use git checkout. In your case:

    git checkout origin/master style.css
    

    This command will update the requested file from the given branch (here the remote branch origin/master).

    Hope this helps

    0 讨论(0)
  • 2021-02-01 14:20

    Go to the location of style.css (may be app/css/ )using console otherwise there will be pathspec error.

    then execute :

    git checkout origin/master style.css

    0 讨论(0)
  • 2021-02-01 14:27

    I intentionally deleted some files from a clone --depth 1 and this brought the main files, and submodule ones, back.

    git checkout . -f && git submodule update --checkout -f 
    
    0 讨论(0)
提交回复
热议问题