git commands Flashcards

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

How would you clone https://github.com/libgit2/libgit into the current directory

A

git clone https://github.com/libgit2/libgit

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

How would you create a snapshot of the current state of all the tracked files in the repository.

A

git commit

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

How would you create a new branch named bugFix that points to current HEAD?

A

git branch bugFix

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

How would you create a new branch named bugFix that points to current HEAD? And update HEAD to point to bugFix?

A

git checkout -b bugFix

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

How would you create a new branch named bugFix that points to the commit at hash c0s0cv0s ?

A

git branch bugFIx c0s0cv0s

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

How would you create a new branch named bugFix at the grandparent of Head?

A

git branch bugFix HEAD~2

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

You are on main branch. bugFix has been updated in parallel with main. How would you create a new commit that has the change of both main and bugFix?

A

git merge bugFix;

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

What kind of merge is it if the HEAD is an ancestor of the branch you merge with?

A

Fast Forward

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

What command takes a set of commits that are not the ancestor of the current branch and brings them in to be ANCESTORS of the latest commit on the current branch. (Example: you want to get recent changes from main to be ancestors of bugFix.)

A

git checkout bugfix; git rebase main

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

If you don’t like the changes in the last commit, how could you create a new commit that does not include those changes?

A

git revert HEAD

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

How would you copy a series of specific commits (hashes 1234567 and 2345678) to be below your HEAD (current location), AND move the current branch and head pointers to last commit copied.

A

git cherry-pick 1234567 2345678

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

What command would open up an editor that would allow you to interactively move around the last 4 commits on your current branch?

A

git rebase -i HEAD~4

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

How would you permanently mark commit 3456789 with the label version1?

A

git tag version1 3456789

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

How would you get from the remote main, deltas for changes on main, without actually updating the files that display on the local filesystem?

A

git fetch

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

What command would create a new branch namedmyBranchand sets it to trackorigin/main and makes myBranch the current branch?

A

git checkout -b myBranch origin/main

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

What kind of branch do you set up on your local so that, if yoy do a pull, you will get updates from the remote branch. And if you do a push, updates on the local will be uploaded to the branch it is tracking?

A

tracking branch

17
Q

How would you create a new branch bugFix, pointing to where HEAD currently points?

A

git branch bugFix

18
Q

What command shows all the branches and shows where HEAD points?

A

git branch

19
Q

How do you commit with the comment “I fixed a bug”?

A

git commit -m “I fixed a bug”

20
Q

How do you show changes for files that are tracked?

A

git diff

21
Q

How would you get any changes and new files from work area to staging area?

A

git add .

22
Q

How would you see changes you are about to commit?

A

git diff –staged

23
Q

How would you see a history of commits?

A

git log