If you found this article, we don’t need to sell you on the merits of Git. So let’s get right to it.
Install the Latest Version of Git
The default repositories, for the Ubuntu package manager, typically don’t have the latest version of Git. To get the very latest stable version, we just need to add an additional repository that is updated when new versions are released:
sudo add-apt-repository ppa:git-core/ppa # Add the main repository sudo apt-get update
Now install Git:
sudo apt-get install git
Verify Git is installed:
Here is a list of settings you’ll typically want to configure immediately after installing Git.
1 2 3 4
git config --global user.name "put your name here" git config --global user.email "put your email here" git config --global color.ui true git config --global push.default simple
Some Git commands open an editor and ask you to edit a file. There are many editor options available. Here’s how you would configure git to use nano.
sudo apt-get install nano git config --global core.editor "nano"
Add Some Aliases
After working with Git for a while, you may start looking for ways to work more efficiently. Git Aliases are a great way to streamline your workflow. Check out our best-git-aliases GitHub project for a list of our favorite aliases; here are a couple to get you started.
1 2 3
git config --global alias.logg 'log --graph --decorate --oneline --abbrev-commit' git config --global alias.state '!git fetch origin && git remote show origin && :' git config --global alias.sync '!git fetch origin && git remote prune origin && :'
We hope you found this article useful. If you see any mistakes, missing features or ways to improve it, please let us know in the comments below so we can update its contents. If you're willing to link to us, we would sincerely appreciate it!