Tuesday 16 June 2015

Git delete remote file

Sometimes I accidentally pushes too much stuff into remote directory, which makes it messy. In such cases, I would like to delete the excessive branches or files.

To delete a remote directory that is no longer wanted, use the command found here
git rm -r --cached some-directory
git commit -m 'Remove the now ignored directory "some-directory"' 
git push origin master

To delete a branch, use the command found here
git push origin --delete <branchName>

Sometimes git push takes a long time to finish, and a git status shows that: Your branch is Ahead by X commits. In this case, the local commits may contain something wrong. To revert to the current commit in the remote repository, use the command here
git reset --hard origin/master

No comments:

Post a Comment