recentpopularlog in

kme : oops   13

linux - Remove a certain line from Bash history file - Super User |
You can achieve removal from the history file using the commandline in two steps:

Typing history -d <line_number> deletes a specified line from the history in memory.
Typing history -w writes the current in-memory history to the ~/.bash_history file.

The two steps together remove the line permanently from the in-memory history and from the .bash_history file as well.
bash  history  security  cya  oops  solution  fuckina 
march 2019 by kme
Removing sensitive data from a repository - User Documentation
git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA' \
--prune-empty --tag-name-filter cat -- --all
> Rewrite 48dc599c80e20527ed902928085e7861e6b3cbe6 (266/266)
> Ref 'refs/heads/master' was rewritten

git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin
git reflog expire --expire=now --all
git gc --prune=now
security  github  git  oops  howto  solution 
may 2017 by kme
version control - Change the author of a commit in Git - Stack Overflow
Github has a public script for that and it works great! – rodowi Jun 25 '12 at 0:57

You could do

git rebase -i -p <some HEAD before all of your bad commits>

Then mark all of your bad commits as "edit" in the rebase file. If you also want to change your first commit, you have to manually add it as first line in the rebase file (follow the format of the other lines). Then, when git asks you to amend each commit, do

git commit --amend --author "New Author Name <>"

edit or just close the editor that opens, and then do

git rebase --continue

to continue the rebase.

You could skip opening the editor altogether here by appending --no-edit so that the command will be:

git commit --amend --author "New Author Name <>" --no-edit && \
git rebase --continue

Single Commit

As some of the commenters have noted, if you just want to change the most recent commit, the rebase command is not necessary. Just do

git commit --amend --author "New Author Name <>"

This will change the author to the name specified, but the committer will be set to your configured user in git config and git config If you want to set the committer to something you specify, this will set both the author and the committer:

git -c"New Author Name" -c commit --amend --reset-author

Note on Merge Commits

There was a slight flaw in my original response. If there are any merge commits between the current HEAD and your <some HEAD before all your bad commits>, then git rebase will flatten them (and by the way, if you use GitHub pull requests, there are going to be a ton of merge commits in your history). This can very often lead to very different history (as duplicate changes may be "rebased out"), and in the worst case, it can lead to git rebase asking you to resolve difficult merge conflicts (which were likely already resolved in the merge commits). The solution is to use the -p flag to git rebase, which will preserve the merge structure of your history. The manpage for git rebase warns that using -p and -i can lead to issues, but in the BUGS section it says "Editing commits and rewording their commit messages should work fine."

I've added -p to the above command. For the case where you're just changing the most recent commit, this is not an issue.
git  devel  rewriting  history  commitlog  scm  versioncontrol  oops  solution 
july 2016 by kme
Throw away local commits in git - Stack Overflow
A 'git rebase -i HEAD~4' just ended up staring at me blankly, so what actually worked was:
Simply delete your local master branch and recreate it like so:

git branch -D master
git checkout origin/master -b master

(no commits had been pushed to 'origin' at that point).
git  rebase  oops  gitfu  incantation  devel  sourcecontrol  versioncontrol  solution 
january 2015 by kme
git - How can I remove a commit on github? - Stack Overflow
git push -f origin HEAD^:master
That should "undo" the push.
git  github  devel  oops  maybesolution  gitfu 
june 2014 by kme

Copy this bookmark:

to read