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

后端 未结 14 1864
猫巷女王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 20:59

    Delete all elements in repository:

     git rm -r * -f -q
    

    then:

     git commit -m 'Delete all the stuff'
    

    then:

     git push -u origin master
    

    then:

     Username for : "Your Username" 
     Password for : "Your Password"
    
    0 讨论(0)
  • 2021-01-29 21:00

    First, remove all files from your Git repository using: git rm -r *

    After that you should commit: using git commit -m "your comment"

    After that you push using: git push (that's update the origin repository)

    To verify your status using: git status

    After that you can copy all your local files in the local Git folder, and you add them to the Git repository using: git add -A

    You commit (git commit -m "your comment" and you push (git push)

    0 讨论(0)
  • 2021-01-29 21:00

    This process is simple, and follows the same flow as any git commit.

    1. Make sure your repo is fully up to date. (ex: git pull)
    2. Navigate to your repo folder on your local disk.
    3. Delete the files you don't want anymore.
    4. Then git commit -m "nuke and start again"
    5. Then git push
    6. Profit.
    0 讨论(0)
  • 2021-01-29 21:01

    In my case

    git rm -r .

    made the job

    0 讨论(0)
  • 2021-01-29 21:04

    Delete the hidden .git folder (that you can locate within your project folder) and again start the process of creating a git repository using git init command.

    0 讨论(0)
  • 2021-01-29 21:06

    Warning: this will delete your files, make sure you have a backup or can revert the commit.

    Delete all elements in repository:

    $ git rm -r *
    

    then:

    $ git commit -m 'Delete all the stuff'
    
    0 讨论(0)
提交回复
热议问题