Committing changes
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 areaUse
.to stage all changes ready for commitIf you are in the root directory of your repository,
git add .andgit add -Awill 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, whilegit add -Awill 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")
-astages all changes so you can stage changes and commit with a comment all in one line instead of the separate commandgit add .but only works on files that are already being tracked, so not that useful for newly added files...--amendallows 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
-mto
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--rootreferences the very first commit in a repo
git rebase --interactive <PARENT_OF_COMMIT>
git rebase -i <COMMIT_TO_EDIT>^
git rebase -i --root
Last updated