Git is great. I use it all the time, and when I work in Emacs, I use Magit. It gives you a nice interface to perform tasks and work with code in a git repository.
Let’s add it to the mix!
I’ve created a new setup file, nameley setup-git.el. I suspect that there will be more git related customizations, but for now it will only contain magit specific code.
(require 'setup-package) (package-require 'magit) (global-set-key (kbd "C-x g") 'magit-status) (provide 'setup-git)
Not very much interseting going on here. I’ve used the
package-require function from the previous part to ensure that we have magit installed. Then I bind the function
C-x g just like in ohai-emacs. Running this command will take you to the “git control center” showing you all changes, both staged and unstaged for commit. Press
d to view the diff,
c to commit or maybe
F to perform a fetch or a pull. Take a look at the documentation and this cheat sheet if you’re new to Magit.
The final step is to add
(require 'setup-git) to