Rails Noob's Notes

Because my memory is good but short.

Git

Installation and configuration

This installation description is for Ubuntu.

It is installed by default.

User name and email configuration (for all projects of that user).

git config --global user.name "Krzysztof Kowalski"

git config --global user.email k.kowalski@example.com

User name and email configuration just for that project.

git config --local user.name "Krzysztof Kowalski"

git config --local user.email k.kowalski@example.com

Undo changes

Back to the last commit, when unwanted changes are not commited and not added.

git checkout -- . and then git clean -df

Or

git reset --hard and then git clean -df

Or probably the best way:

git add . and then git reset --hard

Back to the last commit, when unwanted changes are not commited but added.

git reset --hard

Back to the any commit with working tree added to the index or not.

To be sure that all changes are added.

git add .

And then to go back to the pre-pre-last (second to last) commit.

git reset --hard HEAD~2