Just a few useful git aliases I've stumbled upon on the net which I've found useful and use on a pretty regular basis.
Been meaning to post this for a while. I've been using Git for a number of years now and my last two jobs had me using it heavily. I love git and honestly have managed to block the memories of what my life was like when I tried to manage my version control life with Subversion.
We've also been discussing Git a lot in our SDPHP Group. I am not going to get into a long post about the coolness of Git and why you should be using it, that is kind of an old discussion at this point. If you are not using Git nowadays I will assume you (a) Don't want to use Git, (b) Don't have a good enough understanding of Git, (c) Don't know what Git is. If you are in category (c) you are probably not a developer and this will be of no interest to you. If you are in category (a), well then I am sure you have your reasons and they are valid. If you are in category (b) then let me share a few things with you. First are some links to some great resources on how to use Git. These groups know what they are talking about and do a fantastic job explaining things, way better than I could ever do.
- If you a completely new, or new'ish then I strongly suggest starting with Github's tutorial. It covers all the basics and is honestly 90% of what you typically do with Git on a day-to-day basis -> http://try.github.io/levels/1/challenges/1
- Another super simple tutorial which includes links for downloading Git for the various Operating Systems out there -> http://rogerdudler.github.io/git-guide/
- This is a little deeper and more advanced but one you will need to get your head around eventually. A nice article of Git Branching -> http://nvie.com/posts/a-successful-git-branching-model/
- A very short "How-To" with Git. http://terokarvinen.com/2012/git-from-offline-to-network
- A finally a great interactive site that helps you understand Git Branching which was shared by a member of the SDPHP Group -> http://pcottle.github.io/learnGitBranching/
I also did a smaller presentation to the SDPHP Study Group earlier on Aug 26
I hope you find some of this information helpful and/or useful.
One recent project I worked on depended very heavily on Github. If you don't know what Github is it's a hosting service for projects that uses Git version control and if I really needed to explain that to you then the rest of this post probably won't do much for you.
The problem with depending on external services and API is that when they are having a bad day, then you are probably having a bad day. The project I was a part of was a Node application that would have to be built and rebuilt several times on several different machines, we are talking in the thousands. This application would reach out to Github for several modules which were essential to the build process. Needless to say there are ways to architect this solution to remove this dependency but that isn't the point of this post 😉
Github has a great status page which does a good job at keeping you informed on the current going on with the Github platform but the problem with it is you need to go to the page, get the status, and if there is an issue continually return to see if there are any updates. Thanks to developer Romin Irani (@iromin on twitter) you can now interact with Github over IM and more importantly have his GitHub Status Bot send you notifications whenever Github has any sort of disruption, planned or otherwise.
GitHub Status Bot is pretty simple and easy to use. Its worth noting that GitHub Status Bot is not an "official" Github Bot and is hosted Google AppEngine. Romin Irani also makes his source code available on Github
Using GitHub Status Bot is pretty straight forward
- First, simply add email@example.com to your Gtalk buddy list
- Once added send a message to the bot by typing 'help'. This will provide you a list of commands that the bot will respond to.
- 'status' gives you the current system status
- 'last-message' gets the last human communication, status, and timestamp.
- 'messages' will get you a list of the most recent communications with status and timestamp.
- 'subscribe' is a key command, what this does is lets the bot know you want to be notified via Google Talk if GitHub is down.
- 'unsubscribe' will remove yourself from any 'GitHub is down' status updates. I've found, unless I was having issues or needed to keep a close eye on Github that the status message will tend to get a little chatty for day to day following.
- And finally if you just want to be reminded who you have to thank for this awesome service, and what version you are on, type in 'about'
That's pretty much it, hope you find the GitHub Status Bot as helpful as I do.
So I've been asked a couple of times for this post and I keep not getting around to it so thought I would take some time and get this out. My bash prompt is very informative, long, and functional and that is they way I like it. One prompt actually results in 2 lines in my terminal being used. This is my current Bash Prompt in terminal:
- First thing to notice is my command prompt is actually on the second line, below all the information. This is by design.
- The first part of the prompt in the typical username and computer name. Nothing special. A lot of people remove this but I keep it. When all the voices in my head start shouting at each other I can always look at my command prompt and remember who I am.
- Next is my location on the computer. Again, a lot of people will just have this piece represent only the current folder but I like to see the entire path. Main reason is I might have several Project folders on my system and this helps me to see which Project folder I am in.
- Then comes this little piece of magic that I love, my Git Branch. This section only displays when I am in a directory structure related to a Git checkout and shows me which branch of that git checkout I am working on. This section, depending on your system, may require different set ups. Since I am on my OSX system what I am using is
git-prompt.sh). One of the better post on how to install this correctly can be found on a StackOverFlow.com thread. Keep in mind, if I am not on a Git branch none of this section displays, not even the - which makes it is very clean.
- Finally I like to add a time stamp to the end of my prompt. This allows me to return to a console and figure out when I last ran something from that window. It's very helpful. The time doesn't stay current, meaning it won't continue to keep time, it will only show you the time when that prompt was created and that is it.
The prompt does include the different colors for the different sections if your system supports it and most Unix type console do support it. Here is the magic that makes this happen.
There are a couple of ways to play around with this, tweak it until you find what you like, without impacting your system permanently until you want to. At the command prompt simply copy and past the entire line including the word "export", you should be able to see the new prompt immediately. Once you've tweaked it to exactly what you want you can add it to either you
.bash_profile files however you can remove the word export when you do that and just start the line at PS1
If you would like a version without the Git Branch indicator this version should work for you
Here is a link to some other helpful and fun Bash Prompts
Enjoy and Happy Bash'ing
Update: My buddy @johncongdon on twitter pointed out by adding
export GIT_PS1_SHOWDIRTYSTATE=1 to your
.bash_profile then you will also get the status of the Git branch.
Attended another great presentation put on by the San Diego PHP User Group (which I am now a co-organizer of) around a workflow built off Git called Gitflow, presented by John Congdon (@johncongdon). Unfortunately the slides, as good as they are, don't capture all the great discussion and examples that were sparked up from the presentation but its a good start.
As I mentioned, I've taken a more active role is the SDPHP Group so if you have any question feel free to ping me. You can also keep tabs on the groups in the normal spots:
Facebook: San Diego PHP
I've been doing a lot of work with Git lately and its great. I downloaded and installed the Git Bundle for Textmate but it didn't seem to work, always returning the error message "sh: git: command not found". Since I did most of my Git work from the command line I just ignored it but for some reason tonight I decided I needed to fix.
Since I knew Git worked on my system, it must have been something with the way Textmate was configured. I couldn't figure out how to confiugre Textmate to point to my Git install so I guess I cheated and I created a symbolic link on my system to point to my Git install. It seems to have corrected my issue with Textmate.
The command I ran was pretty simple
sudo ln -s /usr/local/git/bin/git /usr/bin/git
That's it, Textmate is now happy with my Git install.