Skip to content

Git commands

initialise a project

git init

update the index

git add .

note:

-|- git add -A | stages all changes git add . | stages new files and modifications, without deletions (on the current directory and its subdirectories). git add -u | stages modifications and deletions, without new files

note: git add -A is equivalent to git add .; git add -u.

(source)

commit + message

see changelog

git commit -m 'message'

commit update

git commit -a -m 'message'
git commit -am 'message'

log

git log

add a new element

git add page.html
# or
git add .

revert a commit

how to revert a single file to a previous version?

git log path/to/file
# or git log -p path/to/file if commit msg not useful
# get the version of the file from the given commit
git checkout <commit> path/to/file
# and commit this modification
git commit