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

merge branches
checkout the branch that will encompass another branch, then
git merge name-of-branch-to-merge-in
so not the one at which you are, but the other one, that should be incorporated
undo the merge
git reset –hard HEAD^
what will git do when you use the git merge command?
look at the branches that it’s going to merge
look back along the branch’s history to find a single commit that both branches have in their commit history
combine the lines of code that were changed on the separate branches together
makes a commit to record the merge
fast-forward merge
when the branch that’s merged in contains next steps for the checked out branch
will move the currently checked out branch forward until it points to the same commit that the other branch is pointing to. So it moves the HEAD (the pointer), it doesn’t create a new commit

When a merge is performed and fails, that is called
a merge conflict
what will I see if a merge conflict occurs?
Git will try to combine as much as it can, but then it will leave special markers (e.g. > > > and < < < ) that tell you where you need to manually fix.
when does a merge conflict happen?
when the exact same line(s) are changed in separate branches
what do the indicators of the merge conflict mean?


resolve merge conflict
remove all conflict indicators
write the piece of the code that causes conflict the way you want it to be, delete all the alternative versions, save, stage and commit the new version
you could also just commit it with all the indicators, but that’s a bit useless, and how will this code work anyways?
! Be careful that a file might have merge conflicts in multiple parts of the file, so make sure you check the entire file for merge conflict indicators - a quick search for < < < (without spaces) should help you locate all of them.
