(window.webpackJsonp=window.webpackJsonp||[]).push([[1112],{1520:function(t,e,a){"use strict";a.r(e);var s=a(31),i=Object(s.a)({},(function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[a("h1",{attrs:{id:"committing"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#committing"}},[t._v("#")]),t._v(" Committing")]),t._v(" "),a("p",[t._v("Commits with Git provide accountability by attributing authors with changes to code. Git offers multiple features for the specificity and security of commits. This topic explains and demonstrates proper practices and procedures in committing with Git.")]),t._v(" "),a("h2",{attrs:{id:"good-commit-messages"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#good-commit-messages"}},[t._v("#")]),t._v(" Good commit messages")]),t._v(" "),a("p",[t._v("It is important for someone traversing through the "),a("code",[t._v("git log")]),t._v(" to easily understand what each commit was all about. Good commit messages usually include a number of a task or an issue in a tracker and a concise description of what has been done and why, and sometimes also how it has been done.")]),t._v(" "),a("p",[t._v("Better messages may look like:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("TASK-123: Implement login through OAuth\nTASK-124: Add auto minification of JS/CSS files\nTASK-125: Fix minifier error when name > 200 chars\n\n")])])]),a("p",[t._v("Whereas the following messages would not be quite as useful:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("fix // What has been fixed?\njust a bit of a change // What has changed?\nTASK-371 // No description at all, reader will need to look at the tracker themselves for an explanation\nImplemented IFoo in IBar // Why it was needed?\n\n")])])]),a("p",[t._v("A way to test if a commit message is written in the correct mood is to replace the blank with the message and see if it makes sense:")]),t._v(" "),a("p",[a("strong",[t._v("If I add this commit, I will ___ to my repository.")])]),t._v(" "),a("h3",{attrs:{id:"the-seven-rules-of-a-great-git-commit-message"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#the-seven-rules-of-a-great-git-commit-message"}},[t._v("#")]),t._v(" The seven rules of a great git commit message")]),t._v(" "),a("ol",[a("li",[t._v("Separate the subject line from body with a blank line")]),t._v(" "),a("li",[t._v("Limit the subject line to 50 characters")]),t._v(" "),a("li",[t._v("Capitalize the subject line")]),t._v(" "),a("li",[t._v("Do not end the subject line with a period")]),t._v(" "),a("li",[t._v("Use the "),a("a",{attrs:{href:"https://en.wikipedia.org/wiki/Imperative_mood",target:"_blank",rel:"noopener noreferrer"}},[t._v("imperative mood"),a("OutboundLink")],1),t._v(" in the subject line")]),t._v(" "),a("li",[t._v("Manually wrap each line of the body at 72 characters")]),t._v(" "),a("li",[t._v("Use the body to explain "),a("strong",[t._v("what")]),t._v(" and "),a("strong",[t._v("why")]),t._v(" instead of "),a("strong",[t._v("how")])])]),t._v(" "),a("p",[a("strong",[a("a",{attrs:{href:"http://chris.beams.io/posts/git-commit/#seven-rules",target:"_blank",rel:"noopener noreferrer"}},[t._v("7 rules from Chris Beam's blog"),a("OutboundLink")],1),t._v(".")])]),t._v(" "),a("h2",{attrs:{id:"amending-a-commit"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#amending-a-commit"}},[t._v("#")]),t._v(" Amending a commit")]),t._v(" "),a("p",[t._v("If your "),a("strong",[t._v("latest commit is not published yet")]),t._v(" (not pushed to an upstream repository) then you can amend your commit.")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit --amend\n\n")])])]),a("p",[t._v("This will put the currently staged changes onto the previous commit.")]),t._v(" "),a("p",[a("strong",[t._v("Note:")]),t._v(" This can also be used to edit an incorrect commit message. It will bring up the default editor (usually "),a("code",[t._v("vi")]),t._v(" / "),a("code",[t._v("vim")]),t._v(" / "),a("code",[t._v("emacs")]),t._v(") and allow you to change the prior message.")]),t._v(" "),a("p",[t._v("To specify the commit message inline:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit --amend -m "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"New commit message"')]),t._v("\n\n")])])]),a("p",[t._v("Or to use the previous commit message without changing it:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit --amend --no-edit\n\n")])])]),a("p",[t._v("Amending updates the commit date but leaves the author date untouched. You can tell git to refresh the information.")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit --amend --reset-author\n\n")])])]),a("p",[t._v("You can also change the author of the commit with:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit --amend --author "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"New Author "')]),t._v("\n\n")])])]),a("p",[a("strong",[t._v("Note:")]),t._v(" Be aware that amending the most recent commit replaces it entirely and the previous commit is removed from the branch's history. This should be kept in mind when working with public repositories and on branches with other collaborators.")]),t._v(" "),a("p",[t._v("This means that if the earlier commit had already been pushed, after amending it you will have to "),a("code",[t._v("push --force")]),t._v(".")]),t._v(" "),a("h2",{attrs:{id:"committing-without-opening-an-editor"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#committing-without-opening-an-editor"}},[t._v("#")]),t._v(" Committing without opening an editor")]),t._v(" "),a("p",[t._v("Git will usually open an editor (like "),a("code",[t._v("vim")]),t._v(" or "),a("code",[t._v("emacs")]),t._v(") when you run "),a("code",[t._v("git commit")]),t._v(". Pass the "),a("code",[t._v("-m")]),t._v(" option to specify a message from the command line:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit -m "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Commit message here"')]),t._v("\n\n")])])]),a("p",[t._v("Your commit message can go over multiple lines:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v('git commit -m "Commit '),a("span",{pre:!0,attrs:{class:"token string"}},[t._v("'subject line'")]),t._v(' message here\n\nMore detailed description follows here (after a blank line)."\n\n')])])]),a("p",[t._v("Alternatively, you can pass in multiple "),a("code",[t._v("-m")]),t._v(" arguments:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit -m "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Commit summary"')]),t._v(" -m "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"More detailed description follows here"')]),t._v("\n\n")])])]),a("p",[a("strong",[t._v("See "),a("a",{attrs:{href:"http://chris.beams.io/posts/git-commit/",target:"_blank",rel:"noopener noreferrer"}},[t._v("How to Write a Git Commit Message"),a("OutboundLink")],1),t._v(".")])]),t._v(" "),a("p",[a("strong",[a("a",{attrs:{href:"https://udacity.github.io/git-styleguide/",target:"_blank",rel:"noopener noreferrer"}},[t._v("Udacity Git Commit Message Style Guide"),a("OutboundLink")],1)])]),t._v(" "),a("h2",{attrs:{id:"stage-and-commit-changes"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#stage-and-commit-changes"}},[t._v("#")]),t._v(" Stage and commit changes")]),t._v(" "),a("h3",{attrs:{id:"the-basics"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#the-basics"}},[t._v("#")]),t._v(" The basics")]),t._v(" "),a("p",[t._v("After making changes to your source code, you should "),a("strong",[t._v("stage")]),t._v(" those changes with Git before you can commit them.")]),t._v(" "),a("p",[t._v("For example, if you change "),a("code",[t._v("README.md")]),t._v(" and "),a("code",[t._v("program.py")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git add README.md program.py\n\n")])])]),a("p",[t._v("This tells git that you want to add the files to the next commit you do.")]),t._v(" "),a("p",[t._v("Then, commit your changes with")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit\n\n")])])]),a("p",[t._v("Note that this will open a text editor, which "),a("a",{attrs:{href:"http://stackoverflow.com/documentation/git/397/configuration/2234/setting-which-editor-to-use",target:"_blank",rel:"noopener noreferrer"}},[t._v("is often"),a("OutboundLink")],1),t._v(" "),a("a",{attrs:{href:"http://stackoverflow.com/documentation/vim/topics",target:"_blank",rel:"noopener noreferrer"}},[t._v("vim"),a("OutboundLink")],1),t._v(". If you are not familiar with vim, you might want to know that you can press "),a("code",[t._v("i")]),t._v(" to go into "),a("strong",[t._v("insert")]),t._v(" mode, write your commit message, then press "),a("code",[t._v("Esc")]),t._v(" and "),a("code",[t._v(":wq")]),t._v(" to save and quit. To avoid opening the text editor, simply include the "),a("code",[t._v("-m")]),t._v(" flag with your message")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit -m "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Commit message here"')]),t._v("\n\n")])])]),a("p",[t._v("Commit messages often follow some specific formatting rules, see "),a("a",{attrs:{href:"http://stackoverflow.com/documentation/git/323/committing/4729/good-commit-messages",target:"_blank",rel:"noopener noreferrer"}},[t._v("Good commit messages"),a("OutboundLink")],1),t._v(" for more information.")]),t._v(" "),a("h3",{attrs:{id:"shortcuts"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#shortcuts"}},[t._v("#")]),t._v(" Shortcuts")]),t._v(" "),a("p",[t._v("If you have changed a lot of files in the directory, rather than listing each one of them, you could use:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git add --all # equivalent to "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"git add -a"')]),t._v("\n\n")])])]),a("p",[t._v("Or to add all changes, "),a("strong",[t._v("not including files that have been deleted")]),t._v(", from the top-level directory and subdirectories:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git add .\n\n")])])]),a("p",[t._v('Or to only add files which are currently tracked ("update"):')]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git add -u\n\n")])])]),a("p",[t._v("If desired, review the staged changes:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git status # display a list of changed files\ngit diff --cached # shows staged changes inside staged files\n\n")])])]),a("p",[t._v("Finally, commit the changes:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit -m "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Commit message here"')]),t._v("\n\n")])])]),a("p",[t._v("Alternately, if you have only modified existing files or deleted files, and have not created any new ones, you can combine the actions of "),a("code",[t._v("git add")]),t._v(" and "),a("code",[t._v("git commit")]),t._v(" in a single command:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit -am "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Commit message here"')]),t._v("\n\n")])])]),a("p",[t._v("Note that this will stage "),a("strong",[t._v("all")]),t._v(" modified files in the same way as "),a("code",[t._v("git add --all")]),t._v(".")]),t._v(" "),a("h3",{attrs:{id:"sensitive-data"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#sensitive-data"}},[t._v("#")]),t._v(" Sensitive data")]),t._v(" "),a("p",[t._v('You should never commit any sensitive data, such as passwords or even private keys. If this case happens and the changes are already pushed to a central server, consider any sensitive data as compromised. Otherwise, it is possible to remove such data afterwards. A fast and easy solution is the usage of the "BFG Repo-Cleaner": '),a("a",{attrs:{href:"https://rtyley.github.io/bfg-repo-cleaner/",target:"_blank",rel:"noopener noreferrer"}},[t._v("https://rtyley.github.io/bfg-repo-cleaner/"),a("OutboundLink")],1),t._v(".")]),t._v(" "),a("p",[t._v("The command "),a("code",[t._v("bfg --replace-text passwords.txt my-repo.git")]),t._v(" reads passwords out of the "),a("code",[t._v("passwords.txt")]),t._v(" file and replaces these with "),a("code",[t._v("***REMOVED***")]),t._v(". This operation considers all previous commits of the entire repository.")]),t._v(" "),a("h2",{attrs:{id:"committing-changes-directly"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#committing-changes-directly"}},[t._v("#")]),t._v(" Committing changes directly")]),t._v(" "),a("p",[t._v("Usually, you have to use "),a("code",[t._v("git add")]),t._v(" or "),a("code",[t._v("git rm")]),t._v(" to add changes to the index before you can "),a("code",[t._v("git commit")]),t._v(" them. Pass the "),a("code",[t._v("-a")]),t._v(" or "),a("code",[t._v("--all")]),t._v(" option to automatically add every change (to tracked files) to the index, including removals:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit -a\n\n")])])]),a("p",[t._v("If you would like to also add a commit message you would do:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit -a -m "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"your commit message goes here"')]),t._v("\n\n")])])]),a("p",[t._v("Also, you can join two flags:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit -am "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"your commit message goes here"')]),t._v("\n\n")])])]),a("p",[t._v("You don't necessarily need to commit all files at once. Omit the "),a("code",[t._v("-a")]),t._v(" or "),a("code",[t._v("--all")]),t._v(" flag and specify which file you want to commit directly:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit path/to/a/file -m "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"your commit message goes here"')]),t._v("\n\n")])])]),a("p",[t._v("For directly committing more than one specific file, you can specify one or multiple files, directories and patterns as well:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit path/to/a/file path/to/a/folder/* path/to/b/file -m "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"your commit message goes here"')]),t._v("\n\n")])])]),a("h2",{attrs:{id:"creating-an-empty-commit"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#creating-an-empty-commit"}},[t._v("#")]),t._v(" Creating an empty commit")]),t._v(" "),a("p",[t._v("Generally speaking, empty commits (or commits with state that is identical to the parent) is an error.")]),t._v(" "),a("p",[t._v("However, when testing build hooks, CI systems, and other systems that trigger off a commit, it's handy to be able to easily create commits without having to edit/touch a dummy file.")]),t._v(" "),a("p",[t._v("The "),a("code",[t._v("--allow-empty")]),t._v(" commit will bypass the check.")]),t._v(" "),a("p",[a("code",[t._v('git commit -m "This is a blank commit" --allow-empty')])]),t._v(" "),a("h2",{attrs:{id:"committing-on-behalf-of-someone-else"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#committing-on-behalf-of-someone-else"}},[t._v("#")]),t._v(" Committing on behalf of someone else")]),t._v(" "),a("p",[t._v("If someone else wrote the code you are committing, you can give them credit with the "),a("code",[t._v("--author")]),t._v(" option:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit -m "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"msg"')]),t._v(" --author "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"John Smith "')]),t._v("\n\n")])])]),a("p",[t._v("You can also provide a pattern, which Git will use to search for previous authors:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit -m "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"msg"')]),t._v(" --author "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"John"')]),t._v("\n\n")])])]),a("p",[t._v('In this case, the author information from the most recent commit with an author containing "John" will be used.')]),t._v(" "),a("p",[t._v("On GitHub, commits made in either of the above ways will show a large author's thumbnail, with the committer's smaller and in front:")]),t._v(" "),a("p",[a("a",{attrs:{href:"http://i.stack.imgur.com/iy2My.png",target:"_blank",rel:"noopener noreferrer"}},[a("img",{attrs:{src:"http://i.stack.imgur.com/iy2My.png",alt:"enter image description here"}}),a("OutboundLink")],1)]),t._v(" "),a("h2",{attrs:{id:"selecting-which-lines-should-be-staged-for-committing"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#selecting-which-lines-should-be-staged-for-committing"}},[t._v("#")]),t._v(" Selecting which lines should be staged for committing")]),t._v(" "),a("p",[t._v("Suppose you have many changes in one or more files but from each file you only want to commit some of the changes, you can select the desired changes using:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git add -p\n\n")])])]),a("p",[t._v("or")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git add -p [file]\n\n")])])]),a("p",[t._v("Each of your changes will be displayed individually, and for each change you will be prompted to choose one of he following options:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("y - Yes, add this hunk\n\nn - No, don’t add this hunk\n\nd - No, don’t add this hunk, or any other remaining hunks for this file.\n Useful if you’ve already added what you want to, and want to skip over the rest.\n\ns - Split the hunk into smaller hunks, if possible\n\ne - Manually edit the hunk. This is probably the most powerful option.\n It will open the hunk in a text editor and you can edit it as needed.\n\n")])])]),a("p",[t._v("This will stage the parts of the files you choose. Then you can commit all the staged changes like this:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit -m "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v("'Commit Message'")]),t._v("\n\n")])])]),a("p",[t._v("The changes that were not staged or committed will still appear in your working files, and can be committed later if required. Or if the remaining changes are unwanted, they can be discarded with:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git reset --hard\n\n")])])]),a("p",[t._v("Apart from breaking up a big change into smaller commits, this approach is also useful for "),a("strong",[t._v("reviewing")]),t._v(" what you are about to commit. By individually confirming each change, you have an opportunity to check what you wrote, and can avoid accidentally staging unwanted code such as println/logging statements.")]),t._v(" "),a("h2",{attrs:{id:"commiting-changes-in-specific-files"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#commiting-changes-in-specific-files"}},[t._v("#")]),t._v(" Commiting changes in specific files")]),t._v(" "),a("p",[t._v("You can commit changes made to specific files and skip staging them using "),a("code",[t._v("git add")]),t._v(":")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit file1.c file2.h\n\n")])])]),a("p",[t._v("Or you can first stage the files:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git add file1.c file2.h\n\n")])])]),a("p",[t._v("and commit them later:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit\n\n")])])]),a("h2",{attrs:{id:"gpg-signing-commits"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#gpg-signing-commits"}},[t._v("#")]),t._v(" GPG signing commits")]),t._v(" "),a("li",[t._v("\nDetermine your key ID\n"),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("gpg --list-secret-keys --keyid-format LONG\n\n/Users/davidcondrey/.gnupg/secring.gpg\n"),a("span",{pre:!0,attrs:{class:"token deleted"}},[t._v("--------------------------------------")]),t._v("\nsec 2048R/YOUR-16-DIGIT-KEY-ID YYYY-MM-DD [expires: YYYY-MM-DD]\n\n")])])]),a("p",[t._v("Your ID is a alphanumeric 16-digit code following the first forward-slash.")])]),t._v(" "),a("li",[t._v("\nDefine your key ID in your git config\n"),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git config --global user.signingkey YOUR-16-DIGIT-KEY-ID\n\n")])])])]),t._v(" "),a("li",[t._v("\nAs of version 1.7.9, git commit accepts the -S option to attach a signature to your commits. Using this option will prompt for your GPG passphrase and will add your signature to the commit log.\n"),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit -S -m "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Your commit message"')]),t._v("\n\n")])])])]),t._v(" "),a("h2",{attrs:{id:"committing-at-a-specific-date"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#committing-at-a-specific-date"}},[t._v("#")]),t._v(" Committing at a specific date")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit -m "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v("'Fix UI bug'")]),t._v(" --date 2016-07-01\n\n")])])]),a("p",[t._v("The "),a("code",[t._v("--date")]),t._v(" parameter sets the "),a("strong",[t._v("author date")]),t._v(".\nThis date will appear in the standard output of "),a("code",[t._v("git log")]),t._v(", for example.")]),t._v(" "),a("p",[t._v("To force the "),a("strong",[t._v("commit date")]),t._v(" too:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("GIT_COMMITTER_DATE=2016-07-01 git commit -m "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v("'Fix UI bug'")]),t._v(" --date 2016-07-01\n\n")])])]),a("p",[t._v("The date parameter accepts the flexible formats as supported by GNU date, for example:")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit -m "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v("'Fix UI bug'")]),t._v(" --date yesterday\ngit commit -m "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v("'Fix UI bug'")]),t._v(" --date "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v("'3 days ago'")]),t._v("\ngit commit -m "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v("'Fix UI bug'")]),t._v(" --date "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v("'3 hours ago'")]),t._v("\n\n")])])]),a("p",[t._v("When the date doesn't specify time, the current time will be used and only the date will be overridden.")]),t._v(" "),a("h2",{attrs:{id:"amending-the-time-of-a-commit"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#amending-the-time-of-a-commit"}},[t._v("#")]),t._v(" Amending the time of a commit")]),t._v(" "),a("p",[t._v("You cam amend the time of a commit using")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit --amend --date="),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Thu Jul 28 11:30 2016 -0400"')]),t._v("\n\n")])])]),a("p",[t._v("or even")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git commit --amend --date="),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"now"')]),t._v("\n\n")])])]),a("h2",{attrs:{id:"amending-the-author-of-a-commit"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#amending-the-author-of-a-commit"}},[t._v("#")]),t._v(" Amending the author of a commit")]),t._v(" "),a("p",[t._v("If you make a commit as the wrong author, you can change it, and then amend")]),t._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[t._v("git config user.name "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"Full Name"')]),t._v("\ngit config user.email "),a("span",{pre:!0,attrs:{class:"token string"}},[t._v('"email@example.com"')]),t._v("\n\ngit commit --amend --reset-author\n\n")])])]),a("h4",{attrs:{id:"syntax"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#syntax"}},[t._v("#")]),t._v(" Syntax")]),t._v(" "),a("ul",[a("li",[t._v("git commit [flags]")])]),t._v(" "),a("h4",{attrs:{id:"parameters"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#parameters"}},[t._v("#")]),t._v(" Parameters")]),t._v(" "),a("table",[a("thead",[a("tr",[a("th",[t._v("Parameter")]),t._v(" "),a("th",[t._v("Details")])])]),t._v(" "),a("tbody",[a("tr",[a("td",[t._v("--message, -m")]),t._v(" "),a("td",[t._v("Message to include in the commit. Specifying this parameter bypasses Git's normal behavior of opening an editor.")])]),t._v(" "),a("tr",[a("td",[t._v("--amend")]),t._v(" "),a("td",[t._v("Specify that the changes currently staged should be added (amended) to the "),a("strong",[t._v("previous")]),t._v(" commit. Be careful, this can rewrite history!")])]),t._v(" "),a("tr",[a("td",[t._v("--no-edit")]),t._v(" "),a("td",[t._v("Use the selected commit message without launching an editor. For example, "),a("code",[t._v("git commit --amend --no-edit")]),t._v(" amends a commit without changing its commit message.")])]),t._v(" "),a("tr",[a("td",[t._v("--all, -a")]),t._v(" "),a("td",[t._v("Commit all changes, including changes that aren't yet staged.")])]),t._v(" "),a("tr",[a("td",[t._v("--date")]),t._v(" "),a("td",[t._v("Manually set the date that will be associated with the commit.")])]),t._v(" "),a("tr",[a("td",[t._v("--only")]),t._v(" "),a("td",[t._v("Commit only the paths specified. This will not commit what you currently have staged unless told to do so.")])]),t._v(" "),a("tr",[a("td",[t._v("--patch, -p")]),t._v(" "),a("td",[t._v("Use the interactive patch selection interface to chose which changes to commit.")])]),t._v(" "),a("tr",[a("td",[t._v("--help")]),t._v(" "),a("td",[t._v("Displays the man page for "),a("code",[t._v("git commit")])])]),t._v(" "),a("tr",[a("td",[t._v("-S[keyid], -S --gpg-sign[=keyid], -S --no-gpg-sign")]),t._v(" "),a("td",[t._v("Sign commit, GPG-sign commit, countermand "),a("code",[t._v("commit.gpgSign")]),t._v(" configuration variable")])]),t._v(" "),a("tr",[a("td",[t._v("-n, --no-verify")]),t._v(" "),a("td",[t._v("This option bypasses the pre-commit and commit-msg hooks. See also "),a("a",{attrs:{href:"http://stackoverflow.com/documentation/git/1330/hooks#t=201609151909429849523",target:"_blank",rel:"noopener noreferrer"}},[t._v("Hooks"),a("OutboundLink")],1)])])])])])}),[],!1,null,null,null);e.default=i.exports}}]);