Git Commands Flashcards

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

Create a new local repository

A

git init

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

Send changes to the master branch of your remote repository:

A

git push origin master

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

Switch from one branch to another:

A

git checkout

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

Push all branches to your remote repository:

A

git push –all origin

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

Fetch and merge changes on the remote server to your working directory:

A

git pull

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

List the files you’ve changed and those you still need to add or commit:

A

git status

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

Pull down the latest changes from the remote server WITHOUT merging them into your branches quite yet.

A

git fetch

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

Apply all the changes from one branch to your current branch. You do NOT want to merge, merely apply everything that has changed (You don’t want a merge message in the history).

A

git rebase BRANCH-TO-PULL-CHANGES-FROM

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

You created a new local branch and want to push it to the server, but it doesn’t exist on the server yet. What is the command to create it and push it to the server at the same time?

A

git push origin BRANCH

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

Create a new branch and switch to it all in one command.

A

git checkout -b NEW-BRANCH

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

You are finished with a local branch you were using for testing. Delete it.

A

git branch -D BRANCH

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

You are completely done with a branch you were testing. You already removed it from your local computer. Delete it from the remote server.

A

git push origin :BRANCH

*Notice the colon “:”

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

You just merged to master and would like to increment the version. Example: that merge puts the product at v0.2.0. Use git to officially tag the release version.

A

git tag -a v0.2.0 -m “version 0.2.0. My message goes here”

*Make sure you have checked out the right branch.

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

You’ve properly tagged the application as v0.2.0. But it’s only a local tag. Push your tags to the remote server.

A

git push –tags

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

You’ve made a few changes, but don’t want to keep them. You would like to reset all your changes back to what they were when you first checked out your current branch.

A

git checkout .

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

You’ve made some changes, but you suddenly need to switch branches to address a different problem. Your changes aren’t ready to be properly committed, but you don’t want to lose them. How can you save your changes while you change to another branch real quick?

A

git stash