Github README.md and readme.md - how to delete one?
Solution 1
The reason that github doesn't have a delete link or button is because a simple 'delete' goes against the nature of a Source Control Version System. The way to remove a file is to remove it locally, usually with a terminal window and the command line with git rm
, commit that change - always with a message - and then 'push' that delete to the repository. If the file is present locally but never git add
ed to git you can just rm filename
the file - but warning, there's no 'confirm' normally at the command line with rm
!
Admittedly, github could have looked to 'package' that all up into a delete page link that, given a text description for reason, could do that but it would be too much 'black magic' and misleading to users learning git and how to use github.
If you want a gui option, there are a lots of git gui tools out there. As you are on a mac, gitx , git-tower and source-tree are all tools that may help. There is also the basic mac-github tool at
http://mac.github.com/
The command line route is shown in the answer by ThiefMaster
More info on the overall git process and what the various commands and concepts are can also be found at: git branch, fork, fetch, merge, rebase and clone, what are the differences?
Solution 2
Simply delete one of the files and commit the deletion.
$ git rm readme.md
$ git commit
$ git push
ljgww
Updated on August 02, 2022Comments
-
ljgww almost 2 years
Somehow I endup with having README.md and readme.md on github. Now these two influence each other so my GitHub.app gets completely confused. Github web site do not have any file delete function.
How to delete one of these files?
-
ljgww over 11 yearsresolved. I have had to remove both readme.md variants using command line tool as follows:
git rm -f readme.md
andgit rm -f README.md
commit, push, and when there is no readme.md listed on github add a new readme.md, commit and push. special thanks to ThiefMaster for valuable hint on command line command path.
-
-
ljgww over 11 yearsthanks you for the explanation of the concept (git tools are very confusing to me, have them several installed, and not a single one is "user friendly" or "logical" to me)
-
ljgww over 11 yearsSo far I figured out that command line git relates to a current folder. Which brings a question in which folder to issue these commands?
-
ljgww over 11 years$ git rm readme.md error: 'README.md' has local modifications
-
ljgww over 11 yearsnow push complains about not being able to push changes to github git push Username: Password: To github.com/xx/xx.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'github.co/xx/xx.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes (e.g. 'git pull') before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details. working on this one... pull do not help either.