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
how to log git commits from a author?
git log --author="(name)"
26
how to log git commits by date?
git log --since='x days ago / dd/[mm]/[yy]'
27
how to log git commits with graphics?
git log --graph
28
how to log git commits of a specific file?
git log (filename)
29
how to log git commits for a specific file even if the file was renamed at one point?
git log --follow (filename)
30
what are git aliases and how to create one?
are ways of shortcuting commands to create: git config [--global] alias.(commandName) "(command)" *(command) excludes the initial 'git' from beginning of line.
31
how to ignore some files?
creating a .gitignore file and placing paths to the folders/files
32
how to log git commits across all branches?
git log --all
33
how to log files from a starting commit to another?
git log (commitID1) (commitID2)
34
how to check changes between working dir and staging area?
git diff
35
how to check changes between working dir and last commit(HEAD)?
git diff HEAD
36
how to check changes between last commit and staging area?
git diff HEAD --staged
37
how to check changes between two commits?
git diff (commitID1) (commitID2)
38
command to check alterations between working dir and staged area for a specific file
git diff (filepath)
39
how to write the difference between the local master and the 'origin' repo master branch?
master and origin/master
40
how to check differences between two branches?
git diff branch1 branch2
41
p4merge
a tool to be evoked by git CLI to resolve merge issues and see differences between areas
42
steps necessary to config a diff/merge tool to be used with git
on config: 1. set the tool name 2. set tool path
43
configure diff or merge tools names to be used with git
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
what does difftool.prompt (boolean) do?
prompts or skips and opens the tool directly
45
How to write a documentation to the github repo?
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
branching is
a new isolated development path that also tracks a different history
47
creating a new branch
git branch (name)
48
going to the newly created branch
git checkout (branchName)
49
renaming an existing branch
git branch -m (actualName) (newName)
50
deleting a branch
git branch -d (name)
51
listing all branches (including remote)
git branch -a
52
creating a new branch and changing to it with the same command
git checkout -b (newBranchName)
53
merging in git is
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
merging a branch to master
(at master) git merge (branchName)
55
merging fast-forwarding method happens when
parent branch has no commits after the off-branching, it simply integrates the parent with the offbranch, usually faster
56
force non fast-forwarding when merging branches
``` git merge (branchName) --no-ff preserves branching history even if one of the branches has no subsequent commits, create a 3-way commit ```
57
rebasing is useful for
when you dont wanna merge a branch yet but there are features in the parent branch that you want to integrate,
58
rebasing a branch to master
(at off-branch) git rebase master
59
git rebase --abort is
when you are resolving rebasing conflicts and dont wan to continue the operation of rebasing
60
git rebase --continue is
when you want to continue resolving rebasing conflicts or finally rebase
61
git pull --rebase does:
instead of creating a merge in branching history, puts your work ahead of all pulled commits and keeps them in the same history
62
tagging in git is and why is it useful?
tagging are references with descriptions or not that point to a commit and generally is used to mark releases and milestones
63
creating a tag
git tag (name)
64
creating an anotated tag
git tag -a (name)
65
shortcut to create an anotated tag
git tag (name) -m "(message)"
66
creating an anotated tag for a previous commit
git tag -a (name) (commitID)
67
force a created tag to point to another commit
git tag (name) -f (commitID)
68
pushing a tag to a remote repo
git push repo/branch (tag) when pushing to a repo, it also pushes the commit the tag is attached to
69
pushing all tags to a remote repo
git push repo/branch --tags
70
how to remote a tag from a remote repo
git tag push repo/branch :(tag)
71
git commit --amend is
a way to rephrase the message from the last commit
72
what is git stashing and why is it useful
its a way of saving the work for later and returning the working dir to the HEAD state
73
creating a git stash
git stash
74
applying the last stashed working dir
git stash apply
75
deleting the last stash created
git stash drop
76
git stash does not include untracked files, how to include it?
git stash -u
77
shortcut to apply and delete a stash
git stash pop
78
how to create a stash/multiple stashes with descriptions?
git stash save -m "(description)"
79
listing all stashes
git stash list
80
applying a specific stash
git stash apply stash@{n}
81
emptying the stash list
git stash clear
82
shortcut to create a stash, relate it and checkout to a branch, apply the stash and drop it
git stash branch (name)