markdown 在OS X上创建一个快乐的Git环境

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 在OS X上创建一个快乐的Git环境相关的知识,希望对你有一定的参考价值。

# Creating a Happy Git Environment on OS X

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

    brew install git bash-completion

Configure things:

    git config --global user.name "Your Name"
    git config --global user.email "you@example.com"
    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).

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 "you@example.com"

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)

以上是关于markdown 在OS X上创建一个快乐的Git环境的主要内容,如果未能解决你的问题,请参考以下文章

如何安装Git到MAC OS X

text 在Mac OS X上使用p4merge作为Git mergetool。

Mac(OS X)中Git安装与GitHub基本使用

Git 和 Mac OS X 上的元音变音问题

如何在 OS X 上的 Git 中处理文件名中的亚洲字符

为啥 git 在错误的目录中查找 git 安装? (OS X)