How can I remove all files in my git repo and update/push from my local git repo?

后端 未结 14 1897
猫巷女王i
猫巷女王i 2021-01-29 20:20

Is it possible to remove all files in a repository and update it with only the files I have in my local machine? The reason is that, there are certain files that is not necessar

14条回答
  •  不思量自难忘°
    2021-01-29 21:16

    You could do it like this:

    cd /tmp
    git clone /your/local/rep  # make a temp copy
    cd rep
    git rm -r *                # delete everything
    cp -r /your/local/rep/* .  # get only the files you want
    git add *                  # add them again
    git status                 # everything but those copied will be removed
    git commit -a -m 'deleting stuff'
    cd /your/local/rep
    git pull /tmp/rep          # now everything else has been removed
    

    There's probably a oneliner for that…

提交回复
热议问题