Git Commands Flashcards
git init
Initializes the folder as the project root and as a git repository
git add index.html
git add .
First adds index.html to the staging area
Second adds all files to the staging area
git add name*
adds files that start with ‘name’ to the staging area
git status
shows the repository status:
staged, unstaged, and untracked files
git commit
opens a text editor in the terminal to write a commit message
git commit -m “commit message”
writes the commit message without opening up an editor, everything in quotes is the message
git log
shows the commit history
git log -p
shows commit history including all files and their changes
git diff
git diff –staged
git diff shows all unstaged changes
adding –staged to see staged changes
git rm filename
will remove the file from the working tree and expect a commit message as to why
git mv oldName newName
renames files in git, expects a commit message
How do you ignore files in git?
create a .gitignore file and commit it
git reset HEAD filename
git reset HEAD -p
reverts staged changes in git
-p options flag to specify the desired changes to reset
git commit –amend
modifies the most recent commit
avoid if possible
git revert HEAD
reverts the latest commit