GIT Flashcards

1
Q

Git

A

A Version Control System for tracking changes in files and coordinating work on them in team

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Creating a repository

A

Git init

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Check for changes

A

Git status

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When there aren’t any files with changes in working directory then the directory is …..

A

Clean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Add a file to list of tracked files

A

Git add

When we add a file to list of tracked files using git add we’re said to stage it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When content is changed

A

The file is tracked but not staged anymore

Need to stage the file again using git add

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Add all the un-staged files in the current directory (and deeper)

A

Git add .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When we run git add

A

Git captures a snapshot of the changes that we can make permanent by committing them to the repository

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Committing changes to repository

A

Git commit -m “message”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Workflow

A

Make changes in the working directory
Use git add to stage them
Use git commit to save changes to repository

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Check if git is installed

A

Open terminal

Git –version

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Repository

A

Special type of directory that keeps track of the files within it

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Git status

A

Tells if the working directory is clean
Tells what files are staged and ready to be committed
Tells what files are tracked but not staged
Tells what files are untracked

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Git log

A

Git keeps track of every commit that we make

We can easily review them using git log

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Brings up the commit history, where every commit is displayed with unique hash code

A

Git log

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Pointer that point to the current commit

A

Git show HEAD

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Go back to previous commit and put the working directory back to the state it was in that time

A

Git checkout [hash code/tag]

Can use either whole hash code or first seven characters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

head detached

A

current commit isn’t the latest commit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

get back to the latest commit

A

git checkout master

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

to add a tag to a commit (can help to memorize important commits)

A

git tag [parameter]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

git tag

A

display previously added tags

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

allow us and others to work on different things, like features, at the same time

A

branches

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

default branch of every repository

A

master branch

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

git branch

A

show existing branches

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
create new branch
git branch [name] | *indicates which branch we are on
26
switch to another branch
git checkout [branch name]
27
display logs that makes reading them a lot easier
git log --graph
28
using .............. we can specify what we want Git to do in a more precise way
flag (eg: --graph)
29
view branches and divergence of commits
git lot --graph --all | can see all commits from all branches
30
neglect unnecessary informations
git log --graph --all --oneline
31
bring changes together
git merge master switch to the branch we want to merge into use git merge followed by the branch name we want to take the changes from
32
we'll face conflict when
there are versions of a file with different changes in branches we want to merge
33
resolve merge conflict
Decide which version to keep Open a text editor and delete the other version along with the special markings commit the file
34
merge tools
as the project grow, more and more merge conflicts appear. It would be great to have a tool to review and resolve them
35
example merge tool
SemanticMerge
36
clone remote repository to our local computer
git clone [url]
37
a name that's automatically given to a remote for which we don't specify a name
origin
38
see where does the remote point to
git remote show origin
39
if the remote has changes in its branch that we want to bring to our local repository
git fetch [remote name by default origin] [remote branch name]
40
merge the fetched changes from remote
git merge origin/master master
41
bring a branch in our local repository up-to-date with its remote version
git pull origin master fetching and merging at the same time we should not have any uncommitted local changes before we use git pull
42
get our local changes to the remote repository
git push origin master pushes commits from our local repository to the remote commit changes before we can push them to the remote
43
staged
files are ready to be committed
44
unstaged
files with changes that have not been prepared to be committed
45
untracked
files aren't tracked by git yet
46
deleted
file has been deleted and is waiting to be removed from Git
47
to remove a file from staging area
git reset [filename]
48
add many files of the same type
git add '*.txt' | don't forget the quotes
49
see more information for each commit where new files were added for the first time where files were deleted
git log --summary
50
add a remote repository
git remote add origin [repository url]
51
tell git to remember the parameters
git push -u origin master | next time simply run git push
52
sometimes when you go to pull you may have changes you don't want to commit just yet. One option you have, other than committing, is to stash the changes
git stash to stash your changes git stash apply to re-apply your changes after your pull
53
take a look at what is different from our last commit
git diff HEAD
54
.......... gives you a good overview of changes you have made and lets you add files or directories one at a time and commit them separately
git diff --staged | staged differences
55
checkout and create a branch at the same time
git checkout -b new_branch
56
remove the actual files from disk | stage the removal of the files
git rm '*.txt'
57
remove an entire folder
git rm -r folder_of_cats | recursively remove all folders and files from the given directory
58
if you happen to delete a file without using 'git rm' you will find that you still have to 'git rm' the deleted files from the working tree
save this step by | git commit -am "Delete stuff"
59
pull requests
allows the boss of the project to look through your changes and make comments before deciding to merge in the change
60
merge conflicts
can occur when changes are made to a file at the same time. just need to decide which code to keep.
61
delete a branch
git branch -d [branch name] will not let you delete a branch that hasn't been merged can use --force (-f) option or use -D which combines -d -f together into one command
62
undoing a git push
git push -f origin loast_known_good_commit:branch_name