I have a git project hosted on github with only one branch ( master
) and only one contributor (me). After my initial commit I added some data files to my local repository that I didn't end up needing. I added to files and committed them at one point, but after deleting them did other commits. The deleted files are not in the remote or local repository, when I do a git diff --stat --cached origin/master
they do not appear and git cherry -v master
shows only the current commit I have without the files.
However, when I do a git push origin master
git tries to compress and write the deleted data files. I cannot figure out why this is happening and how to remove the files from my staging area.
I made many commits trying to get the deleted files to not be pushed. Eventually, because I had so many commits, I backed up all of my files in a separate folder, ran a git reset --hard origin/master
and replaced all of the files in the local repository with the backup files and then did git add *
and git commit -m "comment"
.
You should be running git cherry against origin master shouldnt you? And you shouldnt be running --cached because there could be a prior commit not in your staging area, but not on origin/master, that deleted the files.
git rebase -i
is what I needed, thank you to @choroba for pointing that out. The files were in my local history even though they weren't in the local repository or the commit so I guess git was still trying to push them.
Additionally, thank you to @jbu who correctly noted I should've been running git cherry origin/master -v
to see the commits waiting to be pushed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.