Available from Apple.
Install Homebrew. See page for installation command/options, then run brew doctor
.
brew install git
Set your username and email.
git config --global user.name "Alan Bradley"
git config --global user.email "alan.bradley@example.com"
Set up a global .gitignore
file in the user directory, and set some default ignored files.
git config --global core.excludesfile '~/.gitignore'
echo '.DS_Store' >> ~/.gitignore
Install and configure DiffMerge as the git merge tool.
git config --global diff.tool diffmerge
git config --global difftool.diffmerge.cmd 'diffmerge "$LOCAL" "$REMOTE"'
git config --global merge.tool diffmerge
git config --global mergetool.diffmerge.cmd 'diffmerge --merge --result="$MERGED" "$LOCAL" "$(if test -f "$BASE"; then echo "$BASE"; else echo "$LOCAL"; fi)" "$REMOTE"'
git config --global mergetool.diffmerge.trustExitCode true
Prevent git from saving .orig backup files during merges.
git config --global mergetool.keepBackup false
Generate SSH key pair (see https://help.github.com/articles/connecting-to-github-with-ssh/).
Need to set up multiple Git users (personal and company, etc)? Use aliases.
Generate separate SSH keys (see above) for each Git user, and add the relevant SSH keys to the GitHub accounts. You can test that each key is configured for the desired account by running:
ssh -T git@github.com -i ~/.ssh/incom_rsa
To use a different SSH key for a single command, use the GIT_SSH_COMMAND
env variable. The -i
option sets the desired SSH identity file, and -F
tells it to ignore the git config (which might override the specified identity file). For example, to clone a repository using a desired key:
GIT_SSH_COMMAND="ssh -i ~/.ssh/incom_rsa -F /dev/null" git clone git@github.com:incom/example_repo.git
Finally, create aliases in your ~.bash-profile
:
git-incom = "GIT_SSH_COMMAND='ssh -i ~/.ssh/incom_rsa -F /dev/null' git"
ssh-incom = "ssh -i ~/.ssh/incom_rsa"
Once you have created/cloned a repository, you can configure it to always use the alternate SSH key via the git config:
[core]
sshCommand = ssh -i ~/.ssh/incom_rsa
Add the following to .bash_profile
:
Ensure configuration from .bashrc
is included in the Terminal.
[ -r ~/.bashrc ] && . ~/.bashrc
List git branches by commit date, author, and last commit.
alias git-list-branches="git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'"
Delete all branches that have been merged into master
.
alias git-delete-merged="git branch --merged | grep -v '*' | grep -v 'master' | xargs git branch -d"
Print working directory and current git branch in bash cursor.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
PS1='\n\[\033[32m\][\h \w]\[\033[00m\]$(parse_git_branch)\nbash> '
Install dependencies below as needed.
brew tap mongodb/brew
brew install mongodb-community
Set the default database path in .bash_profile
:
alias mongod="mongod --config /usr/local/etc/mongod.conf"
Install Postgres Mac App or via Homebrew:
brew install postgres
# Set the default database path in `.bash_profile`:
export PGDATA="/usr/local/var/postgres"
brew install redis
Install RVM or rbenv. See page for installation command/options.
Install the Heroku toolbelt.
Install SublimeText and add the PATH to the command line tool (in .bash_profile
):
export PATH="/Applications/Sublime Text.app/Contents/SharedSupport/bin:$PATH"
Install nvm. See page for installation command/options.
Install a Node.js runtime and set as default for new shells:
nvm alias default stable
-
Apple Developer Tools home page
Developer tools for macOS, including the XCode command line tools.
-
DiffMerge home page
Visual merge tool software for Git.
-
Heroku Toolbelt home page
Everything you need to get started using heroku.
-
Homebrew home page
The missing package manager for OS X.
-
nvm GitHub
Manage Node.js versions.
-
Postgres home page
Native macOS application and command line tools for running Postgres.
-
rbenv Github
Lightweight alternative to RVM.
-
RVM home page
Manage ruby versions and gem sets.
-
SublimeText homepage
Graphical text editor.
-
Yarn homepage
JavaScript package manager.