git Flashcards

1
Q

Check what is waiting to be pushed

A

git status, OR:

git push –dry-run

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

Pull all branches

A

git pull –all

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

Switch to branch

A

git checkout branch

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

Merge from master to current branch, do commit

A

git merge master

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

Squash commits interactively

A
git rebase --interactive
Opens vim. Read instructions.
To change: i . edit first words in line as desired
To exit change mode: esc
To save and exit vim: :wq
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Commit with message

A

git commit -m “msg”

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

Undo last commit, leave changes in working dir

A

git reset HEAD~1

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

Undo last commit, delete from working dir

A

git reset –hard HEAD~1

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

Fix last commit message

A

git commit -amend

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

Create a ‘negative’ of a commit that is already pushed

A

git revert [commit id] –no-commit

by default revert commits this negative

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

Add file to staging

A

git add [path]

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

Delete file from git

A

git rm [path]

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

Undo uncommitted changes

A

git checkout , OR

git reset HEAD

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

Cherry pick to current branch

A

git cherry-pick [commit id]

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

Merge to current branch without commit

A

git merge –no-commit

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

Reset types

A
  • -soft: discard last commit, leave in staging area,
  • -mix: discard last commit and add, leave in working folder,
  • -hard: discard last commit, add and any changes to HEAD
17
Q

Show remote names

A

git remote

18
Q

What is the diff between pull and fetch?

A

pull = fetch + merge

19
Q

Add remote

A

git remote add [shortname] [url]

20
Q

Create branch

A

git checkout -b iss53

This is shorthand for:
git branch iss53
git checkout iss53

21
Q

Global option to rebase when pulling

A

git config –global pull.rebase “true”

22
Q

Pull from a specified remote

A

git pull [options] [remote name]

23
Q

What is a ‘bare’ repo?

A

A Git repository that has no working directory

24
Q

What is the diff between pull and fetch?

A

pull = fetch + merge

25
Q

Show local branches

A

git branch

26
Q

Show remote branches

A

git branch -r

27
Q

Show all branches

A

git branch -a

28
Q

Create branch

A

git checkout -b iss53

This is shorthand for:
git branch iss53
git checkout iss53

29
Q

Show remotes - name+url

A

git remote -v

30
Q

Add remote

A

git remote add [shortname] [url]

When you clone, a remote named ‘origin’ is automatically added

31
Q

Fetch specific remote

A

git fetch [remote name]

32
Q

Push to remote

A

git push [remote name] [branch]

33
Q

Rename remote

A

git remote rename [old] [new]

34
Q

Remove remote

A

git remote remove [name]

35
Q

Create branch

A

git branch abcd + git checkout abcd
OR:
git checkout -b abcd

36
Q

Create a negative of a commit or commit range - to undo pushed changes

A

git revert HEAD~2..HEAD