Committing changes
Last updated
Last updated
Description | Commands |
---|---|
Stage files for commit
Use "git addβ to add files to every commit, itβs not a blanket save
Use a wildcard *
to add all files of the same extension to the staging area
Use .
to stage all changes ready for commit
If you are in the root directory of your repository, git add .
and git add -A
will have the same effect, staging all changes in the repository. However, if you are in a subdirectory, git add .
will only stage changes in that directory and its subdirectories, while git add -A
will still stage changes from the entire repository.
git add <FILE_NAME>
git add *.html
git add .
git add -A
Show all changes currently staged for commit
git status
Unstage a file after adding it
git reset HEAD <FILE_NAME>
Commit changes
Comments should be in present tense (e.g. "Add comments and update styling")
-a
stages all changes so you can stage changes and commit with a comment all in one line instead of the separate command git add .
but only works on files that are already being tracked, so not that useful for newly added files...
--amend
allows you to edit the commit e.g. change the comment
git commit -m "<COMMENT>"git commit -am "<COMMENT>"
Change details of the last commit
opens an editor by default or add -m
to
git commit --amend
git commit --amend -m "<NEW_COMMIT_MESSAGE>"
Change a specific commit and all the following commits
^
use this to get the parent of the commit you want to change
--root
references the very first commit in a repo
git rebase --interactive <PARENT_OF_COMMIT>
git rebase -i <COMMIT_TO_EDIT>^
git rebase -i --root