Blog Archives
Updating Email ID and Author Name from multiple commits in Git
Posted by Sayak Sarkar
Multiple Commits:
git filter-branch --commit-filter ' if [ "$GIT_COMMITTER_NAME" = "" ]; then GIT_COMMITTER_NAME=""; GIT_AUTHOR_NAME=""; GIT_COMMITTER_EMAIL=""; GIT_AUTHOR_EMAIL=""; git commit-tree "$@"; else git commit-tree "$@"; fi' HEAD
Single Commit:
To update the author to a specified name [The committer will be set to your configured user in git config user.name and git config user.email]
git commit --amend --author "New Author Name <email@address.com>"
To set both the author and the committer:
git -c user.name="New Author Name" -c user.email=email@address.com commit \ --amend --reset-author
Interactive Rebase
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 <email@address.com>"
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 <email@address.com>" --no-edit && \ git rebase --continue
If there are any merge commits between the current HEAD and your , then git rebase will flatten them (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.”
Reference:
Share this:
- Click to share on Facebook (Opens in new window)
- Click to share on Twitter (Opens in new window)
- Click to email a link to a friend (Opens in new window)
- Click to share on LinkedIn (Opens in new window)
- Click to print (Opens in new window)
- Click to share on Reddit (Opens in new window)
- Click to share on Tumblr (Opens in new window)
- Click to share on Pinterest (Opens in new window)
Posted in git, How-to Guides, Technology
Tags: author, bulk edit commit, commit, edit commit, email, git, git edit commit, git log, git update author, git update commit, github, history, log, rename author, update, update author email, update authorship
Bulk renaming PDFs to their Title names from PDF Metadata
Posted by Sayak Sarkar
Recently, i realized that I have amassed a huge number of e-books over the years and have ended up dumping them within an e-books directory on my laptop. The problem that I now faced was identifying one book from the other because a lot of them had random filenames based upon where I had downloaded them from.
So I now had a couple of requirements:
- An automated way of renaming all of these e-books to their actual titles.
- Removing all duplicate files.
After a little bit of looking around and experimenting around I finally got a Python based solution by Joseph Monaco to my problem. I then forked the orginal repo and added a couple of scripts to it to do my bidding. Now all that I need to do to auto organize all my e-books was this:-
- git clone https://github.com/sayak-sarkar/pdf-title-rename
- export PYTHONPATH=${PYTHONPATH}:$(pwd)/xmp.py
- python pdf-title-rename/pdf-title-rename.py <PATH to my ebooks directory>/*
- ./remove_duplicate.sh
And voila, all of my e-books were now auto renamed to their titles! 🙂
Come to think about it, I can work on repository a bit more to turn it into a full blown package, but then again, I’m feeling a bit lazy now that my goal’s served! Feel free to send me a Pull Request on GitHub if any of you want to automate it further! 😉
Share this:
- Click to share on Facebook (Opens in new window)
- Click to share on Twitter (Opens in new window)
- Click to email a link to a friend (Opens in new window)
- Click to share on LinkedIn (Opens in new window)
- Click to print (Opens in new window)
- Click to share on Reddit (Opens in new window)
- Click to share on Tumblr (Opens in new window)
- Click to share on Pinterest (Opens in new window)
Posted in Fedora, How-to Guides, Python, Technology, Uncategorized, Vim
Tags: auto, auto oganize pdf files, bash, coding, e-books, ebooks, fedora, fedora 18, Fedora 19, Fedora 20, git, github, hacks, Linux, metadata, open source, Operating system, organize, organize ebooks, pdf, pdf metadata, pdf-title-rename, programming, Python, read pdf metadata, remove duplicate pdfs, rename, rename pdf automatically, script, scripting, technology, tips and tricks, title, xmp