General Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

How do I delete the last commit?

A

git reset –hard HEAD~1 (Discard all changed)
or
git reset –soft HEAD-1 (Keep the Changed Files)

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

How to change the last commit message?

A

git commit –amend

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

Delete a Git Branch Remotely?

A

git push origin –delete branchname

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

What is the difference between git pull and git fetch?

A

git pull, is git fetch followed by git merge. git fetch gets the remote changes, they get kept under refs/remotes//. However it doesn’t affect your local branches, and won’t change your working copy. git pull then merges these changes with the local copy

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

How do I undo a ‘git add’ before committing?

A

git reset filename

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

How to remove all untracked files?

A

git clean -f -d

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

How to clone all remote branches?

A

git branch -a

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

How to rename a local branch?

A

git branch -m oldname newname

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

How to revert to a previous Git Commit?

A

git reset -hard commitID

You can use reset as above to revert to a previous commit, this assumes you mean go back to where you were before permanently rather than just take a look (for that you want to checkout an old version). The commit ID, should be as shown in the output of “git log”.

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

How to remove a git submodule?

A

git submodule deinit submodulename
git rm submodulename
git rm –cached submodulename
rm -rf .git/modules/submodulename

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

How to over-write local files when doing a git pull?

A

git fetch –all

git reset –hard origin/master

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

How to discard all unchecked in changes?

A

git checkout – .

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

How to create a new remote branch from the current local branch?

A

git config –global push.default current

git push -u

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

How to restore a delete file?

A

git rev-list -n 1 HEAD – filename
then chekcout that file
git checkout deletingcommitid^ – filename

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

How to revert a single file to a specific previous commit?

A

git checkout commitId filename

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

How to make git ignore permissions or filemode changes?

A

git config core.fileMode false

17
Q

How to tell git to remember your password when using HTTPS?

A

git config –global credentials.helper cache

18
Q

How to preview an old version of a single file?

A

git show commitId:filename

19
Q

How to make git ignore permissions or file mode changes?

A

git config core.fileMode false