have you ever wanted to lose all of your followers by tweeting every single commit message to the world?


In the typical flow of writing software, developers often employ a tool called git to keep track of their changes and collaborate with other developers on the project. When we make a bit-sized number of changes that we want to share with our collaborators on the project or that is a good checkpoint, we commit those changes so others can build on top of them.

If we imagine developers are writing a big collaborative essay, they might make a commit after they feel good about a series of sentences that constitute a complete thought. Then they'd push that commit to their writing partner and the partner could build on it. To make sure there weren't conflicts though, the ideal would be for each writer to work on different parts of the essay. So that's kind of a high-level overview of git & commits.

I read someone's blog post where they did a fantastic job explaining some other git commands with some very nice animations. They were so nice that I copied one of them even though I'm not talking about annyy of these other commands. BUT, if you want to learn some more about git the link to this original post is in the footnotes!

Moving back to software development, depending on what type of developer you are, you might have a different pattern of making commits, some people like committing really frequently while some people make commits way less often. It really depends on the nature of the project, who you're working with, team culture, etc. But a generallly accepted rule is to commit early & often.

Anyways, this article is about losing followers.. so I'm sharing a teeny project about how to send a tweet every time you make a commit 😅

If you'd like to see it in action, follow this account

you'll get lots of these.. actually these are the only tweets that come from this account, lol, enjoy!

The "How-To" is Below...


  1. Get your developer tokens from Twitter's application developer site and make sure your permissions are set to "Read and Write"

Getting your Account API Keys from Twitter.
  1. Fill out the .profiles.ini file with as many different twitter account keys as you would like.
[default] 
CONSUMER_KEY=your_key 
CONSUMER_SECRET=my_secret_key 
ACCESS_TOKEN=my_token 
ACCESS_TOKEN_SECRET=my_secret_token  

[kevindurantactual] 
CONSUMER_KEY=your_key 
CONSUMER_SECRET=my_secret_key 
ACCESS_TOKEN=my_token 
ACCESS_TOKEN_SECRET=my_secret_token  

[kevindurantfanacct] 
CONSUMER_KEY=your_key 
CONSUMER_SECRET=my_secret_key 
ACCESS_TOKEN=my_token 
ACCESS_TOKEN_SECRET=my_secret_token 
  1. run pip install -r requirements.txt to install dependencies (its just tweepy and configparser)

  2. Run python start_tweeting.py default to tweet from the account associated with the keys listed under default in .profiles.ini

  3. When prompted select the folder of the repository you are interested in tweeting out commits for.

  4. Watch as all your fake friends unfollow you.


Verify it Worked

Go to the local repository that you selected to tweet from and find the .git folder.

Note that most operating systems have folders that start with "." hidden. To unhide folders on Mac OSX press Command+Shift+.

hidden folders start with a "."

Once you've found the .git folder, look for 2 files named post-commit and post_commit_hook_autogen.py in the repository's git hooks directory: your_repo/.git/hooks/

Open the post_commit_hook_autogen.py file and verify that the Twitter API credentials you supplied are present in the config dictionary. It should look like this.

python def main():
"""
Get these values from https://apps.twitter.com/
See more detailed instructions in the README.md
"""
cfg = {
    "consumer_key": "some-random-str-thing",
    "consumer_secret": "and-another-one-but-secretive",
    "access_token": "a-long-string-too",
    "access_token_secret" : "a-secretive-long-string"
}

When You Get Tired or Your Follower Count Goes Down to 0

Run the following command: bash stop_tweeting.sh
Supply the path to the repository that you had previously been terrorizing followers from.


Start Tweeting Commits


adapted from this gist I changed the gist a bit by using Tweepy library because I was having some issues with oauth-sign and http-post install from tar.gz was giving me problems and python is just easier. hopefully this makes it a bit more usable for someone else. enjoy!

blog post explaining git commands

GIF Credit for API Keys