Skip to content

Instantly share code, notes, and snippets.

@namnh68
Forked from trey/happy_git_on_osx.md
Created July 29, 2017 10:17
Show Gist options
  • Save namnh68/431135de8feec67f7c366fe727a43398 to your computer and use it in GitHub Desktop.
Save namnh68/431135de8feec67f7c366fe727a43398 to your computer and use it in GitHub Desktop.

Revisions

  1. @trey trey revised this gist Jul 19, 2015. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions happy_git_on_osx.md
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,8 @@

    [Step 1: Install Git](https://gist.github.com/2722851)

    brew install git bash-completion

    Configure things:

    git config --global user.name "Your Name"
  2. @trey trey revised this gist Jun 7, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions happy_git_on_osx.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # Creating a Happy Git Environment on OS X

    [Step 1: Install Git](https://gist.github.com/2722851)

    Configure things:
  3. @trey trey revised this gist May 19, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion happy_git_on_osx.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ### [Step 1: Install Git](https://gist.github.com/2722851)
    [Step 1: Install Git](https://gist.github.com/2722851)

    Configure things:

  4. @trey trey revised this gist May 19, 2012. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions happy_git_on_osx.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,4 @@
    - [Get the installer](http://code.google.com/p/git-osx-installer/)
    - [Get GitX](https://github.com/brotherbard/gitx)
    ### [Step 1: Install Git](https://gist.github.com/2722851)

    Configure things:

    @@ -67,4 +66,4 @@ It's the same command as before, this time just omitting the `--global`.
    ### Sources

    - [PeepCode](http://peepcode.com/products/git)
    - [Git Community Book](http://book.git-scm.com/2_setup_and_initialization.html)
    - [Git Community Book](http://book.git-scm.com/2_setup_and_initialization.html)
  5. @trey trey revised this gist May 19, 2012. 1 changed file with 0 additions and 5 deletions.
    5 changes: 0 additions & 5 deletions happy_git_on_osx.md
    Original file line number Diff line number Diff line change
    @@ -18,11 +18,6 @@ Hit return a couple of times -- leave password blank if you want.

    Paste that code into your [settings page](https://github.com/account) on your repository host(s).

    Set up Global Git Config on your [GitHub account page](https://github.com/account) (the same place you pasted your SSH key). You'll type in some stuff that looks like this:

    git config --global github.user [your_username]
    git config --global github.token [your_token]

    Get happy Git colors. Paste the following into your `~/.gitconfig` file:

    [color]
  6. @trey trey created this gist May 18, 2012.
    75 changes: 75 additions & 0 deletions happy_git_on_osx.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,75 @@
    - [Get the installer](http://code.google.com/p/git-osx-installer/)
    - [Get GitX](https://github.com/brotherbard/gitx)

    Configure things:

    git config --global user.name "Your Name"
    git config --global user.email "[email protected]"
    git config --global alias.co checkout
    git config --global apply.whitespace nowarn

    Setup an SSH key

    ssh-keygen

    Hit return a couple of times -- leave password blank if you want.

    cat ~/.ssh/id_rsa.pub | pbcopy

    Paste that code into your [settings page](https://github.com/account) on your repository host(s).

    Set up Global Git Config on your [GitHub account page](https://github.com/account) (the same place you pasted your SSH key). You'll type in some stuff that looks like this:

    git config --global github.user [your_username]
    git config --global github.token [your_token]

    Get happy Git colors. Paste the following into your `~/.gitconfig` file:

    [color]
    branch = auto
    diff = auto
    status = auto
    [color "branch"]
    current = yellow reverse
    local = yellow
    remote = green
    [color "diff"]
    meta = yellow bold
    frag = magenta bold
    old = red bold
    new = green bold
    [color "status"]
    added = yellow
    changed = green
    untracked = cyan

    Create a `~/.gitexcludes` file and paste in this:

    .DS_Store

    There, now you don't have to ignore that every time.

    ### Bash Fanciness

    Add the following to your `~/.bash_profile` or `~/.bashrc`:

    source /usr/local/git/contrib/completion/git-completion.bash
    GIT_PS1_SHOWDIRTYSTATE=true
    export PS1='[\u@mbp \w$(__git_ps1)]\$ '

    That will add tab auto-completion for Git branches, display the current branch on your prompt, and show a '*' after the branch name if there are unstaged changes in the repository, and a '+' if there are staged (but uncommitted) changes. It will look something like this:

    [user@computer ~/Sites/example.com (master*)]$

    ### Bonus

    If you want to have a different email address for a particular project (a personal project on your work computer, perhaps?), just run this command inside that project's folder:

    git config user.email "[email protected]"

    It's the same command as before, this time just omitting the `--global`.

    ### Sources

    - [PeepCode](http://peepcode.com/products/git)
    - [Git Community Book](http://book.git-scm.com/2_setup_and_initialization.html)