Udacity lesson 5 Flashcards
point out certain commits in order to let them stand out
git tag -a some_tag -m “Message to be added”
-a stands for annotated. You can also add a message through -m
last commit: just like above, the commits somewhere before:
git tag -a tags_name commit_s_number_in_7_digits -m “Message”
see all tags that are in the repository
git tag
but to see where they are - git log
what does git tag -a blah do?
it it adds a tag to the last commit. The tag is visible if you want to see all the commits, also with –oneline
delete a tag
git tag -d tag_name
how do branches work?
you move the pointer called head to the specific commit in a specific branch. That branch then appears in your code editor, and there the next commit will be added.
So if you point at the last commit of one of the existing branches, it will add to that branch. If you point your “head” somewhere in the middle of the branch, it will create a new branch from there.
create a new branch
situate the pointer at the right commit somehow
git branch name_of_branch
switch between branches
git checkout name_of_the_branch_to_switch_to
start a new branch at a certain commit
git branch name_of_the_branch commits_number
git checkout name_of_the_branch
or your could do the first one also with the name of the branch that’s on the same commit now (it’s HEAD is there) as the one you want
list out the branches in a repository
git branch
what happens when you run git checkout branch_name?
removes all files and directories from the Working Directory that Git is tracking (files that Git tracks are stored in the repository, so nothing is lost)
goes into the repository and pulsl out all of the files and directories of the commit that the branch points to
how to know in which branch I am?
git branch
the one with * is the current one
delete a branch
switch to another branch
git branch -d branch_name
why isn’t it deleting my branch? what to do?
because it has unique commits
merge it with some other branch or
git branch -D branch_name
Switch and create branch in one command
git checkout -b new_branch_name
see commits of all branches in a single output
git log –oneline –graph –all
–graph creates the visualization of the tree
–all ensures all branches are represented