Github Flashcards

1
Q

How to check the current git CLI version?

A

git version

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

How to init a local git repository?

A

git init [(repo_name)]

With (repo_name), it creates a folder instead.

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

What is a stash in github?

A

Its a snapshot of a state that is stored for later use, after creating one, the working dir returns to the previous commit state.

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

How to create a stash in git CLI?

A

git stash

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

How to seek help for a git command?

A

git help [(command_name)]

if no command_name is specified, git shows general commands help.

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

How to set the current username and password of the git user on the global level?

A

git config –global user.name (name) and

git config –global user.email (email).

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

How to clone a github repo?

A

git clone (repo.git)

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

how to list a git config in the console

A

git config –list

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

how to add to the staging area: a single file, all files

A

git add (filename) | git add .

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

How to commit a staging area?

A

git commit -m or git commit, to comment with an editor

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

How to express add all already tracked files and commit then?

A

git commit -am “message”

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

How to open the config file with the chosen editor

A

git config -e

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

Where is the global and local git config file stored?

A

global: C:/Users/Youruser/.gitconfig
local: inside the .git folder

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

What is the usefulness of git pull (repo) [(branch)]?

A

to put your local repo in sinc with the remote one in case someone made a change before.

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

Whats the difference between fetch and pull?

A

Fetch only updated the references while pull updates the references and downloads the differences.

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

What is forking?

A

Forking means you will get a copy of a remote repo to your github ID (not to your local computer)

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

how to list all tracked files?

A

git ls-files

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

how to unstage files?

A

git restore –staged

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

how to remove newly created files from working dir

A

git restore (filename)

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

how to move/rename files?

A

git mv (actual_dir/name) (new_dir/name)

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

why is the command git add -A useful?

A

If renaming or changing dir of files without using git mv, the git will see that as two operations: the deletion of a file, and the addition of another, it cannot match the index of the two operations as if it belongs to the same file, thus creating a new file index if you decide to commit.

This can lead to problems when pulling for example, because instead of replacing a file with index X, it may replace another file with another index instead.

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

how to remove any git files?

A

git rm (filename)

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

how to log git commits?

A

git log

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

how to log git commits in one line?

A

git log –oneline

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

how to log git commits from a author?

A

git log –author=”(name)”

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

how to log git commits by date?

A

git log –since=’x days ago / dd/[mm]/[yy]’

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

how to log git commits with graphics?

A

git log –graph

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

how to log git commits of a specific file?

A

git log (filename)

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

how to log git commits for a specific file even if the file was renamed at one point?

A

git log –follow (filename)

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

what are git aliases and how to create one?

A

are ways of shortcuting commands
to create:
git config [–global] alias.(commandName) “(command)”

*(command) excludes the initial ‘git’ from beginning of line.

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

how to ignore some files?

A

creating a .gitignore file and placing paths to the folders/files

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

how to log git commits across all branches?

A

git log –all

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

how to log files from a starting commit to another?

A

git log (commitID1) (commitID2)

34
Q

how to check changes between working dir and staging area?

A

git diff

35
Q

how to check changes between working dir and last commit(HEAD)?

A

git diff HEAD

36
Q

how to check changes between last commit and staging area?

A

git diff HEAD –staged

37
Q

how to check changes between two commits?

A

git diff (commitID1) (commitID2)

38
Q

command to check alterations between working dir and staged area for a specific file

A

git diff (filepath)

39
Q

how to write the difference between the local master and the ‘origin’ repo master branch?

A

master and origin/master

40
Q

how to check differences between two branches?

A

git diff branch1 branch2

41
Q

p4merge

A

a tool to be evoked by git CLI to resolve merge issues and see differences between areas

42
Q

steps necessary to config a diff/merge tool to be used with git

A

on config:

  1. set the tool name
  2. set tool path
43
Q

configure diff or merge tools names to be used with git

A

git config [–global] diff.tool (toolname)
git config [–global] difftool.path ‘path\to\file.exe’

git config [–global] merge.tool (toolname)
git config [–global] mergetool.path ‘path\to\file.exe’

44
Q

what does difftool.prompt (boolean) do?

A

prompts or skips and opens the tool directly

45
Q

How to write a documentation to the github repo?

A

create a README.md (md stands for mark-down) and pushes it to github remote repo.

# symbol makes a primary text size
## makes a secondary
### tertiary
nothing- writes normal text
46
Q

branching is

A

a new isolated development path that also tracks a different history

47
Q

creating a new branch

A

git branch (name)

48
Q

going to the newly created branch

A

git checkout (branchName)

49
Q

renaming an existing branch

A

git branch -m (actualName) (newName)

50
Q

deleting a branch

A

git branch -d (name)

51
Q

listing all branches (including remote)

A

git branch -a

52
Q

creating a new branch and changing to it with the same command

A

git checkout -b (newBranchName)

53
Q

merging in git is

A

the merging of branches alterations, if two files with the same index was modified, then a merging conflict needs to be resolved, often with git mergetool

54
Q

merging a branch to master

A

(at master) git merge (branchName)

55
Q

merging fast-forwarding method happens when

A

parent branch has no commits after the off-branching, it simply integrates the parent with the offbranch, usually faster

56
Q

force non fast-forwarding when merging branches

A
git merge (branchName) --no-ff
preserves branching history even if one of the branches has no subsequent commits, create a 3-way commit
57
Q

rebasing is useful for

A

when you dont wanna merge a branch yet but there are features in the parent branch that you want to integrate,

58
Q

rebasing a branch to master

A

(at off-branch) git rebase master

59
Q

git rebase –abort is

A

when you are resolving rebasing conflicts and dont wan to continue the operation of rebasing

60
Q

git rebase –continue is

A

when you want to continue resolving rebasing conflicts or finally rebase

61
Q

git pull –rebase does:

A

instead of creating a merge in branching history, puts your work ahead of all pulled commits and keeps them in the same history

62
Q

tagging in git is and why is it useful?

A

tagging are references with descriptions or not that point to a commit and generally is used to mark releases and milestones

63
Q

creating a tag

A

git tag (name)

64
Q

creating an anotated tag

A

git tag -a (name)

65
Q

shortcut to create an anotated tag

A

git tag (name) -m “(message)”

66
Q

creating an anotated tag for a previous commit

A

git tag -a (name) (commitID)

67
Q

force a created tag to point to another commit

A

git tag (name) -f (commitID)

68
Q

pushing a tag to a remote repo

A

git push repo/branch (tag)

when pushing to a repo, it also pushes the commit the tag is attached to

69
Q

pushing all tags to a remote repo

A

git push repo/branch –tags

70
Q

how to remote a tag from a remote repo

A

git tag push repo/branch :(tag)

71
Q

git commit –amend is

A

a way to rephrase the message from the last commit

72
Q

what is git stashing and why is it useful

A

its a way of saving the work for later and returning the working dir to the HEAD state

73
Q

creating a git stash

A

git stash

74
Q

applying the last stashed working dir

A

git stash apply

75
Q

deleting the last stash created

A

git stash drop

76
Q

git stash does not include untracked files, how to include it?

A

git stash -u

77
Q

shortcut to apply and delete a stash

A

git stash pop

78
Q

how to create a stash/multiple stashes with descriptions?

A

git stash save -m “(description)”

79
Q

listing all stashes

A

git stash list

80
Q

applying a specific stash

A

git stash apply stash@{n}

81
Q

emptying the stash list

A

git stash clear

82
Q

shortcut to create a stash, relate it and checkout to a branch, apply the stash and drop it

A

git stash branch (name)