Reputation: 4590
I have a local repo where I have put a file 'notes' where i keep some text about my own observations and concerns. When I commit and push to the remote repo I must remove the file. Before I initially made the commit I ran git rm --cached notes
but this apparently did not work because after I pushed the notes file appeared on github.
So what I did locally was run rm
again (somehow it works this time) and do a
git commit --amend
and then git show --stat --oneline HEAD
and I notice notes has been removed.
But now in order to push I must merge the remote changes into my local repo because
Updates were rejected because the tip of your current branch is behind its remote counterpart.
So I run a pull but this fails as well with:
CONFLICT (modify/delete): notes deleted in HEAD and modified in 5bfdf....
What do I need to do to simply delete the notes files from this commit both locally and remotely?
Upvotes: 1
Views: 227
Reputation: 4029
git pull
. This will pull notes from repo.git rm -f notes
git commit
git push
Basically aim is to bring local and remote in sync and then deleting "notes" file.
Upvotes: 0
Reputation: 142422
When I commit and push to the remote repo I must remove the file
If you don't want to commit the file but still to able to modify it locally use
https://git-scm.com/docs/git-update-index
--assume-unchanged
git update-index --assume-unchanged <path>
In case you need to print out list of files marked with the --assume-unchanged
flag:
git ls-files -v|grep '^h'
What do I need to do to simply delete the notes files from this commit both locally and remotely?
First of all pull any changes from the server and then do your changes.
git pull origin <branch>
git add -A .
git rm --cached notes
git commit -m ...
git push origin <branch name>
Upvotes: 1
Reputation: 107
Of course there are my friends , check out these two links:
-An article about solving git conflicts. Has a specific paragraph for you issue.
-Another post about the same issue with loads of suggestions.
My own suggestion is to either get a merge tool or use the the existing GIT tool which will make your life much easier.
Good luck
Upvotes: 0