Share single .bashrc across multiple linux machines

Often I manage many servers and find myself wishing I had the same shortcuts available on my workstation, also present on the server.

Normally I’d use puppet to manage the .bashrc or .bash_profile, but my workstations don’t have a puppet master. To work around this, I store my .bash_profile on github, and have a script to update it automatically.

Here is the script to update my bash_profile

       curl -L > ~/.bash_profile

The actual bash profile is located here

    alias ls='ls -G'
    alias sl='ls -G'
    alias up='cd ..'
    alias redo='sudo \!-1'
    alias sdou='sudo'
    alias suod='sudo'
    alias sodu='sudo'
    alias tailf='tail -f'
    # Open sublime text editor with command subl
    if [ ! -f /usr/local/bin/subl ]; then /bin/ln -s /Applications/Sublime\ /usr/local/bin/subl; fi;

Now on every machine I manage, I run the following command just once

    curl -L | bash -x

After that, I can just execute the bashupdate alias to pull down the latest version.

    spuder@Spuders-MacBook-Pro:~$ bashupdate

Open a new terminal, or source your ~/.bash_profile and you will instantly have the new changes. Pretty slick right?

Recovering from lost git commit messages

I posted a question and answer to stack overflow that explains how to undo the dangerous -c flag in git.

If ever you accidentially overwrite a commit message using git commit –amend, you can easily undo it by search the .git/logs directory. There will still be a hash that points to the previous object which will contain the original message. 



Changing the author on git commits

Some of the users at my company have been accidentally creating and pushing git commits as the root user.


While trying to setup a script to block these commits, I found an interesting quirk of git.

Many guides online suggest amending the git author like so:

git commit --amend --author

This unfortunately only changes the author, and not the committer. To prove this I created the following test.

Set the user name and email

git config "bad user" --replace-all
git config ""

Now make a commit and check the  output of git log.

git log
commit bf4343f6a41978ef5c1236c558aeab9415d17601
Author: bad user <>

Change the author

git commit --amend --author "good guy <>"

Check the full output of the last commit. You will notice that while the author is correct, the committer is incorrect.

git log --format=full
commit 52ee52afde053b5c2102760011359dd4ad7fea47
Author: good guy <>
Commit: bad user <>


The correct way to change the author *and* the committer is with the following command:

git config "good guy" --replace-all
git config ""

git commit --amend --reset-author

Now everything works properly

commit 52ee52afde053b5c2102760011359dd4ad7fea47
Author: good guy <>
Commit: good guy <>