Reputation: 1380
My gitignore file looks like this:
# Ignore bundler config.
/.bundle
# Ignore all logfiles and tempfiles.
/log/*
!/log/.keep
/tmp
coverage/
public/system/
.DS_Store
.env
logfile
development.log
For whatever reason I keep ending up with my development.log file present in my commits and in pull requests. Right now I have an open pull request with the full development.log file present. How do I remove it?
I've tried the following:
End up with The current branch resource has no upstream branch. To push the current branch set the remote as upstream, use git push --set-upstream origin resource. I do that and then I check my PR and the file is still there because clearly it's a no-edit.
I've also tried
The problem here is that the file is present locally, and should be, but I want it stripped from the PR.
How do I remove a file from a pull request but not remove it locally?
Upvotes: 2
Views: 11228
Reputation: 2278
If you want to keep the changes just move them to a different branch both of these work:
rename the file in your IDE, commit and push the change without staging the renamed file, then checkout the correct branch, rename it back to what it was, stage, commit and push to the correct branch.
git rm --cached <filepath>
commit and push the change without staging the deleted file back, move to the correct branch, then stage, commit and push the file.
Upvotes: 0
Reputation: 24347
First remove the log file from the git index while leaving it on disk with the --cached
option:
git rm --cached log/development.log
Then check in the file removal:
git commit -m 'remove development log'
Upvotes: 8
Reputation: 464
If you already pushed that file just delete the file and commit the deleted file and push to remote.
If only committed not pushed into remote just try git reset HEAD~1
(The number 1 means reset one commit) remove the file and push to remote.
Upvotes: 0