问题
I clone my repo where I have some folders and files:
!git clone https://{username}:{password}@github.com/{username}/{project}.git
then I change current directory:
%cd {project}
remove a folder:
!rm -rf "/content/{project}/sample_data"
check status:
!git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: sample_data/README.md
deleted: sample_data/anscombe.json
deleted: sample_data/california_housing_test.csv
deleted: sample_data/california_housing_train.csv
deleted: sample_data/mnist_test.csv
deleted: sample_data/mnist_train_small.csv
no changes added to commit (use "git add" and/or "git commit -a")
do commit:
!git commit -m "Removed all"
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
deleted: sample_data/README.md
deleted: sample_data/anscombe.json
deleted: sample_data/california_housing_test.csv
deleted: sample_data/california_housing_train.csv
deleted: sample_data/mnist_test.csv
deleted: sample_data/mnist_train_small.csv
no changes added to commit
and push:
!git push origin master
After that my folder sample_data
is still in my repo. What am I doing wrong?
回答1:
Before you can commit you need to stage your changes:
git add --all
Stage all the changes
Then run git commit -m "Your message"
again.
As you can see here after running git commit -m "Message"
no changes added to commit
Git told you that nothing was added to the commit.
回答2:
Ensure you are in the default branch:
git checkout master
. The rm -r command will recursively remove your folder:
git rm -r folder-name
. Commit the change: ... Push the change to your remote repository
来源:https://stackoverflow.com/questions/58224869/how-to-remove-folder-on-github-using-coab