Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Friday, August 28, 2015

Get a Git Cheat Sheet

I've been playing around with Sublime Text and a customizable Cheat Sheet package.  One reason I did this was to store a Git cheat sheet.  Hear are a few I found online just by searching "Git Cheat Sheet":

http://overapi.com/git/


http://zrusin.blogspot.com.au/2007/09/git-cheat-sheet.html


http://www.git-tower.com/blog/git-cheat-sheet/


Sometimes we do things the way we have always done things not realizing there's an easier or better way to do it.  To a computer geek, CI usually means continuous integration, but it can also mean continuous improvement.  Let's face it, it always nice to learn something new and share with our work colleagues or online community.  After all, that's one reason why we blog about these things.  So grab a Git cheat sheet and share something you learned with a friend.

Links
http://zrusin.blogspot.com.au/2007/09/git-cheat-sheet.html
http://overapi.com/git/
http://www.git-tower.com/blog/git-cheat-sheet/
Google Git Cheat Sheets

Friday, August 21, 2015

How to Add Your Current Git Branch to Your Terminal Prompt in Unix/Mac OSX?

1. Download the git-prompt.sh file from github using the curl command in the terminal window.
~ ? curl -Lo .git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh           

2. Add the following to your .bash_profile or .bashrc file:
if [ -f ~/.git-prompt.sh ]; then                                                                                            
   source ~/.git-prompt.sh                                                                                                  
   export PS1='\W\e[1;32m$(__git_ps1 "(%s)")\e[m\$ '                                                            
fi                                                                                                                                       

This small script adds an if statement to check if the file exists, sets the source to .git-prompt.sh, and set the PS1 variable to point to the __git_ps1 function in the .git-prompt.sh file.  The \e[1;32m and \e[m\ are color tags used to color the branch text.  

When you navigate to a folder that contains a git repository you should see something like the following:
GitProjectFolder (Master) $ git checkout NewBranch                                                           
GitProjectFolder (NewBranch) $                                                                                         


Links
Change the Terminal Command Prompt
Customizing the Color of Your Terminal Prompt

Sunday, August 2, 2015

Turn on GIT Autocompletion in Mac OSX



if [ -f ~/.git-completion.bash ]; then
   source ~/.git-completion.bash
fi
  1. Open up terminal and navigate to your root/home directory: cd ~
  2. Download git-completion.bash from github.com via the terminal by typing the following:          curl -Lo .git-completion.bash https://github.com/git/git/raw/master/contrib/completion/git-completion.bash 
  3. Put the following in you .bashrc or .bash_profile in you root/home directory:  
    if [ -f ~/.git-completion.bash ]; then
       source ~/.git-completion.bash
    fi
  4. Restart Terminal
  5. Navigate to you git repository
  6. Type "git a"+tab and you should see "git add" or try "git h"+tab and you should see "git help"

Links
Bash Scripting: How to
Bash Beginners Guide 
Advanced Bash Scripting