If you do not already have an editor set up for use with Git at the command line, read this section of Pro Git. master). Loveyoubye. When we worked on GitHub, the basic work cycle was fork > edit > commit The -m flag is for the message (“added my github name”) on the commit - every commit needs a commit message. policy to keep your master branch, on GitHub too, clean of changes you It’s worth taking the time to learn how to care for one properly. The former is what happens by default; the latter never happens by accident. A properly formed Git commit subject line should always be able to complete the following sentence: Notice how this doesn’t work for the other non-imperative forms: Remember: Use of the imperative is important only in the subject line. It’s always better to be explicit though. all the source code of the Don’t be afraid to commit project. Keep in mind: This has all been said before. Keeping them clean isn’t strictly necessary, but it’s But for recording changes the git commit command should also be run. On your See https://gist.github.com/grawity/4392747 for a discussion of the different In any case, the separation of subject from body pays off when browsing the log. A diff will tell you what changed, but only the commit message can properly tell you why. For example: Nothing more need be said; if the reader wonders what the typo was, she can simply take a look at the change itself, i.e. when you edit a file, you commit it as soon as you save it. Metadata. When you’ve made all the changes that you’d like me to accept A few examples: Each of the seven rules you’re reading about right now are written in the imperative (“Wrap the body at 72 characters”, etc.). How should issue tracking IDs, pull request numbers, etc. and merge the master: So now we have replicated the full cycle of work we described in the previous way you expect, and doing things the explicit way helps make what you are new branch is called amend-my-name. git blame, revert, rebase, log, shortlog and other subcommands come to life. When viewing a list of commits, there are various commands depending on how much info you want to see. I use an IDE every day (IntelliJ IDEA) and have used others extensively (Eclipse), but I have never seen IDE integration for Git that could begin to match the ease and power of the command line (once you know it). For example: Commit messages with bodies are not so easy to write with the -m option. Besides, space is precious when you’re trying to keep them to 50 chars or less. There’s nothing you need to re-invent. When I first learned how to use Git add, commit and push it was in the terminal. The recommended one is: This checks out the previously-committed version of the file. > pull request > merge. The Command Line method git commit -m "Subject" -m "Description..." The first -m option is the subject (short description), and the next is the extended description (body). more recent ones will not. You’re better off writing the message in a proper text editor. repository. based on master, for new work to go into: git checkout is a command you’ll use a lot, to switch between branches. the master branch: If you have a changed tracked file - a tracked file is one that Git is The repository you cloned from - yours - can be referred to as origin. Now, fetch updated information from your GitHub fork (origin), Strive for atomic commits (a topic for a separate post). And because it doesn’t get used or taken care of, it remains unstructured and inconsistent. While many repositories’ logs look like the former, there are exceptions. In any case, the separation of subject from body pays off when browsing the log. module. On GitHub you guessed it…. Though not required, it’s a good idea to begin the commit message with a single short (less than 50 character) line summarizing the change, followed by a blank line and then a more thorough description. For example, take a look at these gems from my early days committing to Spring: Yikes. Spell these things out, remove the guesswork, and make it all as simple as possible. particular branch. way past it, you’re inviting trouble. Look at Spring Boot, or any repository managed by Tim Pope. Assuming that Here’s the full log entry: And now git log --oneline, which prints out just the subject line: Or, git shortlog, which groups commits by user, again showing just the subject line for concision: There are a number of other contexts in Git where the distinction between subject line and body kicks in—but none of them work properly without the blank line in between. These are described at: This is a great timesaver: if GitHub has your public keys, you can do all Git is insanely powerful; IDEs are too, but each in different ways. Indeed, many of them are assumed in the way certain Git commands function. This tutorial assumes you have now added your public key to your GitHub A team’s approach to its commit log should be no different. And if I like your changes, I’ll merge them. be referenced? The recommendation is to do this at 72 characters, so that Git has plenty of room to indent text while still keeping everything under 80 characters overall. them to GitHub. Using the -f flag for Git operations is to be avoided. Make commit to the staging area: The -m flag is for the message (“added my github name”) on the commit - some further change to attendees_and_learners.rst, and run git status: Some of the changes in attendees_and_learners.rst will be committed, and the In Git this would be “git add README.md”: In the text box write in your commit message (if you’re wanting to know how to write better commit messages I found this article helpful). I can how to generate a public key. A good text editor can help here. managing - it will warn you that you can’t switch branches without either