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
Q

create new branch

A

git branch [name]

*indicates which branch we are on

26
Q

switch to another branch

A

git checkout [branch name]

27
Q

display logs that makes reading them a lot easier

A

git log –graph

28
Q

using ………….. we can specify what we want Git to do in a more precise way

A

flag (eg: –graph)

29
Q

view branches and divergence of commits

A

git lot –graph –all

can see all commits from all branches

30
Q

neglect unnecessary informations

A

git log –graph –all –oneline

31
Q

bring changes together

A

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
Q

we’ll face conflict when

A

there are versions of a file with different changes in branches we want to merge

33
Q

resolve merge conflict

A

Decide which version to keep
Open a text editor and delete the other version along with the special markings
commit the file

34
Q

merge tools

A

as the project grow, more and more merge conflicts appear. It would be great to have a tool to review and resolve them

35
Q

example merge tool

A

SemanticMerge

36
Q

clone remote repository to our local computer

A

git clone [url]

37
Q

a name that’s automatically given to a remote for which we don’t specify a name

A

origin

38
Q

see where does the remote point to

A

git remote show origin

39
Q

if the remote has changes in its branch that we want to bring to our local repository

A

git fetch [remote name by default origin] [remote branch name]

40
Q

merge the fetched changes from remote

A

git merge origin/master master

41
Q

bring a branch in our local repository up-to-date with its remote version

A

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
Q

get our local changes to the remote repository

A

git push origin master
pushes commits from our local repository to the remote
commit changes before we can push them to the remote

43
Q

staged

A

files are ready to be committed

44
Q

unstaged

A

files with changes that have not been prepared to be committed

45
Q

untracked

A

files aren’t tracked by git yet

46
Q

deleted

A

file has been deleted and is waiting to be removed from Git

47
Q

to remove a file from staging area

A

git reset [filename]

48
Q

add many files of the same type

A

git add ‘*.txt’

don’t forget the quotes

49
Q

see more information for each commit
where new files were added for the first time
where files were deleted

A

git log –summary

50
Q

add a remote repository

A

git remote add origin [repository url]

51
Q

tell git to remember the parameters

A

git push -u origin master

next time simply run git push

52
Q

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

A

git stash
to stash your changes
git stash apply
to re-apply your changes after your pull

53
Q

take a look at what is different from our last commit

A

git diff HEAD

54
Q

………. 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

A

git diff –staged

staged differences

55
Q

checkout and create a branch at the same time

A

git checkout -b new_branch

56
Q

remove the actual files from disk

stage the removal of the files

A

git rm ‘*.txt’

57
Q

remove an entire folder

A

git rm -r folder_of_cats

recursively remove all folders and files from the given directory

58
Q

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

A

save this step by

git commit -am “Delete stuff”

59
Q

pull requests

A

allows the boss of the project to look through your changes and make comments before deciding to merge in the change

60
Q

merge conflicts

A

can occur when changes are made to a file at the same time. just need to decide which code to keep.

61
Q

delete a branch

A

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
Q

undoing a git push

A

git push -f origin loast_known_good_commit:branch_name