- Everything that's not saved - like the code we are creating, our files, directories and changes - lives here.
- This is a file that stores the information about what will go in your next commit - Files and directories that we explicitly add to the staging area. Also known as index.
- Here is were the files are commmited and where the project up to date lives.
- git config --global user.email [email protected]
- git config --global user.name yourName (To configure only the current repository, avoid using --global)
Add all files in directory (include hidden ones)
- git add -A
- git add *.extension
- git reset HEAD
- Create a file named .gitignore
- Write inside the name of the files and directories Git should ignore
- git log
- To exit git log when the log is too long, press Q
- git log
- Find the hash key to the required commit (no need to copy the full hash, a few characters from the beginning would be enough)
- git checkout
- In order to work with this commit without overwrite your actual branch, move files to a new branch using - git checkout -b <new_branch_name>
- NOTE: When you checkout an earlier commit, you are now in a "detached HEAD" state, this means that you are no longer on the commit that is being pointed to by the HEAD. The HEAD, in git, is a pointer to the most recent commit of whichever branch you are currently on.
- git branch
- git checkout -b <new_branch_name>
- git checkout <branch_name>
- From the branch where we want to "update"
- git merge <branch_name>
- To exit the message window while merging (in case it appears), use - esc + ctrl + zz or - esc + :wq (both commands perform save and exit)
- git branch -d <branch_name>
- git remote add origin "url"
- git remote -v (checks out the remote repository)
- git push origin <branch_name> (push to GitHub)