From https://www.educative.io/ Flashcards
How do you know which git repo is the main source?
All git repos are the same.
There is no concept no a central server that hold the “golden” source.
Instead, we maintain our own source. A server or host may be in charge but fundamentally they are all the same.
What are the 4 phases a file tracked by git will go through?
This image is missing some arrows, what are they?

Make cards for overall workflow for:
installing
Connecting
backing up
pushing
pulling
starting new
etc
What does git status do?
Displays the state of the repo and staging area
Gives info on whether a file has been changed or staged
What does git log do?
gives a log of commits
can use –graph to see branching
use –all to see all branches
Add and commit changes in one message (only for already tracked files)
git commit -a
What happens if you do and do not use the -m with a commit?
With, looks for a message within quotation marks
without it opens nano and you can type the message there
See the specific changes (not just whether a file has changed)
git diff
Clone a repo from the harddrive
Clone a repo from github
git clone folderName targetfoldername (don’t git init first)
git clone https://github.com/ianmiell/shutit (don’t git init first)
What does git reset do?
What flag does it use by default
unstages files
–mixed
What does git reset –hard do?
Reverts files on your computer to the last commit
Revert files on your computer to the last commit
git reset –hard
unstage a single file
unstage all files
git reset filenameanddirectory
git reset –mixed
View log but only the title
git log –oneline
view branching log
git log –graph
create a new branch at head
git branch branchname
show all branch names
git branch
view all branches in log
git log –graph –all
The head can point to branch tag but not to arbitrary commits
t or f
f
it can point to arbitrary commits as a floating head
A branch is the same as a tag
t or f
f
branches also have a history
tags do not
but are otherwise the same
View all tags
git tag
create a tag where the head is
create a tag somewhere else
git tag tagname
git tag tagname pointername (works with 6e3574ba4ff1b53dcbf776c6613037b156bc2e30)
A branch is just a pointer
t or f
A tag is just a pointer
t or f
T
Tags and branches can both maintain a branch as logged in git log
t or f
t
tags do it too apparently
History info is lost in detatched head if you don’t have a pointer
t or f
f
it’s not lost it’s just not displayed by git log anymore
If you type in the commit code it will display
Merge two branches
git merge branchname
What does git merge attempt to do?
What if there are conflicts?
there are two branches, they have some common ancestor, merging takes all the changes from the common ancestor to the branch end and attempts to apply it to the head branch.
it makes all changes and automatically commits it all
If there are conflicts, add flags –no-ff –no-commit
It copies new files into the working directory and stages them
Changes files it adds new lines of code into old files (in a specific format) for the user to work through. It does not stage them.
If there are conflicts on the same line of code, what happens?
You decide. Git pauses.
How do you handle conflicts?
There are different workflows
Fix one of the files and commit with that one
Can leave the mess (but easy to forget it’s there)
What happens if you try to commit when you haven’t worked through conflicting files?
It will stop you.
How do you commit if you don’t want to work through conflicts yet?
Add the files.
You can commit with un
What’s a pull request
A pull request – also referred to as a merge request – is an event that takes place in software development when a contributor/developer is ready to begin the process of merging new code changes with the main project repository.
Save changes you’ve made without making a commit
git stash
Load your stashed files
gish stash pop
What happens to conflicts when popping?
Same as conflicts in merging. creates a file showing both versions
Can you commit with unstaged popped files?
no
How do you stash again for different changes?
It adds it to the stack of stashes
when you stash pop, it only deals with the top level
How do you show the actual changes for a stash?
For most recent files:
git stash show
For more recent changes:
git stash show -p
For specific:
git stash show -p stash@{0}
git stash show –patch stash@{0}
–patch - to show what’s changes
How do you ‘load’ a state from the middle of a stash stack?
git stash apply stash@{1}
git stash drop stash@{1}