----BEGIN CLASS---- [13:57] #startclass [13:57] Roll call [13:57] Priyanka Saggu [13:57] Piyush Aggarwal [13:57] pooja sulakhe [13:58] Welcome to the tenth session in the GNU Emacs series. [13:58] Today, we will be going through the shortcuts of Magit. [13:58] Devesh Verma [13:58] I hope all you have watched the video that I sent to the mailing list. [13:58] Aman Verma [13:59] Magit is an interface to the Git version control system written for Emacs. [13:59] In the FLOSS world, we always talk about "commit early, commit often", and hence VCS integration with your editor is very important. [14:00] Since you are using GNU Emacs for all your work, having an interface for the same can greatly help in productivity. [14:00] Like Org-mode, Magit is one of the most important and powerful packages that makes GNU Emacs very popular! [14:01] I hope you have also installed Magit, and added the requires and "C-x g" shortcut in your Emacs configuration file [14:01] This can save you lot of time, when you want to check the Magit buffer and perform Git operations [14:02] From the terminal, clone this repo for testing, $ git clone https://gitlab.com/shakthimaan/operation-blue-moon.git [14:02] Say, to /tmp/operation-blue-moon.git [14:02] Open GNU Emacs, and then open the README.md file in the project. [14:04] Add two lines in two different places in the README.md file. [14:04] Hi everyone! [14:04] Those who would be flying from New Delhi, let's catch up at some events in Delhi too! [14:04] sorry mbuf , misfired [14:05] You should have added the following entry in your Emacs configuration already: [14:05] (global-set-key (kbd "C-x g") 'magit-status) [14:05] The "C-x g" command is used to open the Magit status buffer [14:06] In GNU Emacs 26.1, the Magit buffer says "magit:operation-blue-moon.git" in the modeline [14:06] It also shows in the top the Head, and latest commit [14:06] This is followed by "Unstaged changes", "Staged changes" and "Recent commits" [14:07] If there is nothing staged, then you will not see anything in the "Staged changes". [14:07] You can toggle visibility of the current section using: [14:07] => TAB [14:08] You can cycle visibility of the section and its children using: [14:08] => C-TAB [14:08] You can cycle visibility of all sections in the buffer using: [14:08] => S-TAB [14:10] You can move no the next entry using: [14:10] => n [14:10] You can move to the previous entry using: [14:10] => p [14:10] If you want to move to the next section, you can use: [14:10] => M-n [14:10] Similarly, if you want to move to the previous section in the Magit buffer, you can use: [14:10] => M-p [14:11] You have added two lines in two different places in the README file. [14:12] If you go to the "Unstaged changes", and hit TAB, it will show the changes [14:12] Even if you have multiple changes to a file, you can selectively stage one or more changes. You can stage a change using: [14:12] => s [14:13] Go ahead and stage one of the change. You will see that this change (hunk) is moved to the "Staged changes" [14:13] You can unstage a change at the point using: [14:13] => u [14:14] If you want to stage all the changes in the working tree, you can use: [14:14] => S [14:14] Similarly, if you want to unstage all the changes, you can use: [14:14] => U [14:15] The capital 'S', and 'U' refers to all the changes. [14:16] If you have a new cloned repository, you need to ensure that your name and e-mail address are included in .git/config file inside the project repository [14:16] For example: [14:16] [user] [14:16] name = Shakthi Kannan [14:16] email = author@shakthimaan.com [14:17] Go ahead and update the .git/config with your user and email details. Since, you are in the project repository directory and have the README file, you can just C-x C-f and open .git/config in a buffer, and update the same. [14:18] To make a commit, you can use: [14:18] => c [14:18] It will open up a *magit-commit-popup* buffer with Switches, Options and Actions [14:19] In order to make a commit, press "c" for Commit Action [14:19] You will then be given a COMMIT_EDITMSG buffer where you can type the commit message [14:20] Once, you have finished typing the commit message, you can make the final commit using: [14:20] => C-c C-c [14:20] You will then be brought back to the Magit buffer [14:21] If you want to push the changes to the remote repository, you can use: [14:21] => P [14:21] It will again open a *magit-push-popup* buffer with Switches, Configure and Push options [14:22] To simply push master to remote origin/master, you can use: [14:22] => u [14:24] If you want to pull from the remote repository, you can use: [14:24] => F [14:24] And again to pull into master from origin/master, you can use: [14:24] => u [14:25] If you want to abort making a commit, you can use: [14:25] => C-c C-k [14:26] In the magit status buffer, you can explore the logging history by starting with: [14:26] => l [14:26] This will open the *magit-log-popup* buffer, and again you have Switches, Options and Actions available for you [14:27] To view the current log, you can use: [14:27] => l [14:27] If you want to see the Reflog, you can use: [14:27] => r [14:28] Anytime, you want to quit the buffer, and want to go back to the Magit status buffer, you can use: [14:28] => q [14:29] In the "Recent commits" in the Magit status buffer, you can view the commit changes by using: [14:29] => RET [14:29] IIt will open a magit-revision buffer with the commit changes and Git summary [14:30] You can create a new branch using: [14:30] => b [14:30] It will open a magit-branch-popup buffer with options and actions [14:31] If you want to create a tag version, you can use: [14:31] => t [14:31] And it will open a *magit-tag-popup* buffer give you options to create and delete tags. [14:31] This is useful when you want to make tagged releases for your project [14:32] If you want to reset the current master to something different, you can use: [14:32] => x [14:33] Stashing is useful if you want to temporarily keep aside your changes, because you have something else to work on in the project. [14:33] To stash or apply the stash changes you can start the *magit-stash-popup* buffer using: [14:33] => z [14:34] If you want to only fetch your remote changes, you can use: [14:34] => f [14:35] You have already learn about Ediff. You can also open from the Magit status buffer using: [14:35] => e [14:36] When you want to bisect the history for debugging or troubleshooting, you can use: [14:36] => B [14:36] As how you can create branches from Magit, you can also merge them using: [14:36] => m [14:37] If a project has sub-modules, you can add, update, list them using the *magit-submodule-popup* buffer. To see the Actions available, use: [14:37] => o [14:38] From the README.md buffer, if you want to see the display edit history of the file, you can use: [14:38] => M-x magit-blame [14:39] In this Blame buffer, you can ask for the commit at the point using: [14:39] => RET [14:40] Magit will open a new magit-revision buffer with the exact commit where this line was added/updated [14:40] You can move to the next chunk in this buffer using: [14:40] => n [14:40] You can move to the previous chunk in this buffer using: [14:41] => p [14:41] If you want to move to the next chunk in the same commit, you can use: [14:41] => N [14:42] If you want to move to the previous chunk in the same commit, use: [14:42] => P [14:42] If you want to turn off Magit blame mode, you can use: [14:42] => q [14:43] If you want to gitignore a file, you can use: [14:43] => i [14:45] You can initialize a Git repository from inside GNU Emacs using: [14:45] => M-x magit-init [14:45] Similarly, you can clone a repository using: [14:45] => M-x magit-clone [14:46] To start using rebasing, you can use: [14:46] => r [14:46] It will provide you with the *magit-rebase-popup* buffer, and you can use "i" to rebase interactively. [14:47] The video that I shared in the mailing list has good examples on how to rebase with Magit. [14:47] In any of the popup buffers, if you want to select a switch, just type the switch shortcut, and it will get selected. [14:48] It will get highlighted, and you know the switch is on. [14:48] You can open the diff buffer using: [14:49] => d [14:49] The *magit-diff-popup* buffer has options to show diff for unstaged, staged and working tree [14:50] To see the help or dispatch popup, you can use: [14:50] => h [14:50] OR [14:51] => ? [14:51] There are other commands for cherry-picking, reverting, applying patches etc that you can try out as homework. [14:52] These are some basic Magit commands that you will use on a daily basis. [14:53] As I have mentioned to you earlier to use GNU Emacs on a daily basis, using Magit will greatly help you in committing early and committing often. [14:53] Once you start using it, you will realize, how fast is the interface between editing and VCS. [14:53] This ends this session on Magit. [14:53] Any questions? [14:54] Roll call [14:54] Priyanka Saggu [14:54] Nabarun Pal [14:54] Bhavin Gandhi [14:55] Akshay Gaikwad ----END CLASS----