Git commands Flashcards
Create a new repo with git -> set username
git config –global user.name “your name goes here”
Create a new repo with Git -> create a repo to work in
mkdir example
cd example
git init
(git init in existing folder is also possible I think)
see info about your Git repo
git status
add new file to Git repo
git add example.py
commit changes with message following the command,
what happens if not using a specific command for message?
git commit -m “creating example.py”
-m is to use the message that follows, otherwise git will bring up an editor to create the commit message
how to ignore files in your Git staging area?
with a .gitignore file
what files are usually added to a .gitignore file?
__pycache__
venv
env
.pytest_cache
.coverage
command to get to know more about gitignore
git help gitignore
command to see the history of the commits you made
git log command
command to change where we are in our history
git checkout THEHASHOFTHESHAYOUWANTTOGOTO
-> puts you in a ‘detached HEAD’ state
-> no branch is made
what is a HEAD?
the SHA you happen to be looking at, at any time.
It means what Git thinks you have checked out.
what does ‘detached HEAD’ state mean?
your HEAD is pointing to a SHA that does not have a branch (or label) associated with it
after changing to another SHA, how do you get back to where you were? (the last SHA committed to the master branch)
git checkout master
what does git checkout master do with the HEAD?
makes the head point to the SHA marked by the label, or branch, master
command to create a new branch
git checkout -b my_new_feature