Version control is an important aspect of any project and Atom comes with basic Git and GitHub integration built in.
In order to use version control in Atom, the project root needs to contain the Git repository.
The Alt+Cmd+ZAlt+Ctrl+Z keybinding checks out the HEAD
revision of the file in the editor.
This is a quick way to discard any saved and staged changes you've made and restore the file to the version in the HEAD
commit. This is essentially the same as running git checkout HEAD -- <path>
and git reset HEAD -- <path>
from the command line for that path.
This command goes onto the undo stack so you can use Cmd+ZCtrl+Z afterwards to restore the previous contents.
Atom ships with the fuzzy-finder package which provides Cmd+TCtrl+T to quickly open files in the project and Cmd+BCtrl+B to jump to any open editor. The package also provides Cmd+Shift+BCtrl+Shift+B which displays a list of all the untracked and modified files in the project. These will be the same files that you would see on the command line if you ran git status
.
An icon will appear to the right of each file letting you know whether it is untracked or modified.
Atom can be used as your Git commit editor and ships with the language-git package which adds syntax highlighting to edited commit, merge, and rebase messages.
You can configure Atom to be your Git commit editor with the following command:
git config --global core.editor "atom --wait"
The language-git package will help remind you to be brief by colorizing the first lines of commit messages when they're longer than 50 or 65 characters.
The status-bar package that ships with Atom includes several Git decorations that display on the right side of the status bar:
The currently checked out branch name is shown with the number of commits the branch is ahead of or behind its upstream branch. An icon is added if the file is untracked, modified, or ignored. The number of lines added and removed since the file was last committed will be displayed as well.
The included git-diff package colorizes the gutter next to lines that have been added, edited, or removed.
This package also adds Alt+G Down and Alt+G Up keybindings that allow you to move the cursor to the next or previous diff in the current editor.
If the project you're working on is on GitHub, there are also some very useful integrations you can use. Most of the commands will take the current file you're viewing and open a view of that file on GitHub - for instance, the blame or commit history of that file.
The branch comparison shows you the commits that are on the branch you're currently working on locally that are not on the mainline branch.