Git Commands Flashcards

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

Add current working directory to the repository

A

git add .

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

Initialize a Git repository

A

git init

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

What command do you use to see what file was changed in your repository since the last commit

A

git status

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

Commit staged changes with a message

A

git commit -m ‘[message goes here]’

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

Track new file or stage file for commit

A

git add [file name]

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

Stage and commit all changes

A

git commit -a

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

What commas do you use to list the branches of a repository?

A

git branch

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

Switch branch

A

git checkout [branch name]

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

Merge branch to current working branch

A

git merge [branch name]

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

What command would you use to delete a branch label

A

git branch -d [branch name]

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

Stage and commit all changes with a message

A

git commit -am ‘[message goes here]’

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

Who would you upload changes from a repository named origin from your computer to a Github repository named master?

A

Git push origin master

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

Who would you download changes from a GitHub repository called upstream to a master repository in your computer?

A

Git pull upstream master

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

How do you view the commits history of the repository you are working on?

A

git log

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

What command is used to compare to commits in git

A

git diff [commit id] [commit id]

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

How would you check what are the differences between the working area and the staging area

A

git diff

16
Q

How would you check what are the differences between the staging area and the latest commit

A

git diff –staged

17
Q

After checking an older commit, how do you get back to the current commit with out knowing its ID?

A

git checkout master

18
Q

Who do you create a new branch in a repository?

A

git branch [branch name]

19
Q

Who would you create and move to a new branch using a single command?

A

git checkout -b [new branch]

20
Q

How would you merge a branch called new_feature in to the master branch

A

git merge master new_feature

21
Q

What command will list all remote repositories connected to the repository you are in?

A

git remote

22
Q

Who do you connect a remote repository to your repository?

A

git remote add [remote name] [remote url]

23
Q

What command will print the urls of your remote repository that you push to and pull from?

A

git remote -v

24
Q

Who do you upload data to a remote git repository?

A

git push [remote name] [branch name]

25
Q

Who do you download changes from a remote git repository?

A

git pull [remote name] [branch name]

26
Q

How would you copy a repository from GitHub to your computer and set it as a remote?

A

git clone [github url]

27
Q

Which command will show the local copies of remote branches?

A

git branch -a

28
Q

Add change to previous commit

A

git commit –amend