git status --ignored
will show you what is being ignored.git commit --amend -m "an updated commit message"
to update your latest commit message if you made a typo. You can also add additional files to a commit by adding them before running this command.
git commit --amend --no-edit
to keep the previous commit message.git status
will show a list of files that contain uncommitted changes. These files are grouped into two sections: uncommitted changes that have been staged (e.g., youâve done git add
on these) and uncommitted files that have not been staged. đĄ Tip: This command is super useful for spotting hidden files that sneak their way into commits if you donât have them ignored/your .gitignore
set up yet (Iâm looking at you .DS_Store
).A diff will show you what has changed in the codebase, and the commit message is what tells you why something has changed the way it has.
<type>(<scope>): <subject>
<body>
<footer>
I think the most important parts are the subject and body. Iâm a big fan of type too. I havenât used footer, because the convention in teams Iâve work on is to include Jira ticket numbers in the commit subject, and I also havenât used scope, which hasnât had an obvious use in my particular projects so far.
Example commit without a footer.
git commit -m "chore(server): JIRA-123 - Update routing dependencies in Node server
The previous version of the routing library in the Node server is not compatible with the latest OurCoolAPI changes."
Example commit with a footer.
git commit -m "chore(server): Update routing dependencies in Node server
The previous version of the routing library in the Node server is not compatible with the latest OurCoolAPI changes.
Resolves: JIRA-123
Related: PR #87, PR #86"
To help make atomic commits, you can stage chunks of code â you donât have to stage an entire file at once!3 in VS Code thereâs a way to visually select chunks to stage, as shown in the image below. You can also right click on the section of code you want to stage and an open will appear in the context menu for staging/un-staging the selected range.
From the command line, you can do this with the git add --patch
and git add --interactive
for interactive modes.4
.gitignore
templates.commits.md
or some âscratch paperâ type file handy where you can write out commits so you can paste them into your terminal. This can make it easier to make sure your commit message is formatted properly, especially if you have more than just a one-line commit title.