Git Commands Flashcards

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

git log

A

Displays all the commits, history along with commit hash, who committed and the date and time of commit

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

git log –oneline

A

Just shows commit hash and commit message

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

git log –name-only

A

Shows git log information with list of files that were changed in that commit

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

git log –author=’max’

A

list commits only from this author max

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

git log -1

A

only list the last commit, the most latest one

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

git checkout -b sarah

A

Create a new branch and checkout to that branch

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

git checkout sarah

A

switch to an existing branch

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

git branch -d max

A

To delete a branch

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

git branch

A

Command to list all branches

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

What is HEAD in git repository?

A

HEAD is where you are right now in the git reposito

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

git log –graph –decorate

A

to see the graphical view of how the branches were created like from which branch to which branch

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

git remote add origin http://git.example.com/sarah/story-blog.git

A

To add a remote repository for a local repository

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

git push origin master

A

to push your local repository changes to the origin which is your remote repository

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

git pull origin master

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

git fetch origin master

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

git merge origin/master

A
16
Q

get rebase master

A

If you are working in a branch and want to merge with master but if by that time the master branch had also been updated, we can rebase the master

17
Q

git rebase -i HEAD~4

A

Interactively rebase last 4 commits

18
Q

git command to rebase last 4 commits. Like keep the first commit and merge the 3 after commits to the first one

A

Change the word to squash

19
Q

git cherry-pick <commit></commit>

A
20
Q

git reset –soft HEAD~1

A

reset but still keep the changes that were made
1 is the number of commits you want to reset

20
Q

git revert <commit></commit>

A
21
Q

git reset –hard HEAD~1

A

hard option to lose the chnages that were made on that commit
1 is the number of commits you want to reset

22
Q

git stash

A

to stash changes within a branch temporarily

23
Q

git hash-object <first-story.txt></first-story.txt>

A

to find the git hash of a file

24
Q

Use git cat-file command to view the contents of a commit

A
25
Q

You can also use git cat-file command to view the contents of a hash-object

A
26
Q
A