github Flashcards

1
Q

What is cloning?

A

Copying the repository from GitHub.com to your local machine.

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

Command to clone a repo.

A

git clone

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

Proper use of git clone

A

Create a new folder & cd into it. Then use git clone with the repo’s url.

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

What is a remote?

A

A url where a repo pushed up to. Basically just the url where the repo exists online.

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

Command to view a list of any existing remotes in your repo.

A

git remote or git remote -v (verbose for more info)

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

Command to add a new remote.

A

git remote add (name is usually origin)

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

Command to push code to github.

A

git push

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

Command to push a local branch to a remote branch with a different name.

A

git push origin name1:name2

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

Command to rename master to main.

A

git branch -M main

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

What is a remote tracking branch?

A

The last time you communicated with a particular remote repo, this is a pointer that points to the most recent changes on that repo’s master branch. So it’s basically a bookmark which shows the most recent change on the main branch from the origin.

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

Command to see where remote tracking branch currently is.

A

git branch -r

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

Command to see what your project looked like when you cloned it from github.

A

git checkout origin/main

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

Command to get the online repo up to date with your local machine.

A

git push origin main

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

When you clone a repo, by default it is connected to origin/master. If you want to switch to another branch you use the ________ command.

A

git checkout /origin/branchname

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

Command to create a new local branch from the remote branch of the same name.

A
git switch 
(This will set the branch up to track the remote branch origin/remoteBranchName. So it basically creates a new branch and automatically connects it to main in the same way that the original branch is)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is fetching?

A

When a remote repo you’re working with gets updated and you want to get the updates from it.

17
Q

When you fetch, where does the code from the remote repo go?

A

Directly into your local repo. It does not automatically merge those changes into your local repo.

18
Q

Command to fetch branches & history from a specific remote repo.

A

git fetch

19
Q

Command to fetch fetch just one branch from a remote.

A

git fetch

20
Q

What is pulling?

A

Retrieves changes and actually updates our HEAD branch with whatever changes are retrieved from the remote. So it automatically updates your working directory with the new changes.

21
Q

Pulling is similar to combining which two operations?

A

fetch & merge

22
Q

Command to pull from a remote branch.

A

git pull

23
Q

Where are the changes merged to when pulling?

A

Whichever branch the command is run from.

24
Q

Command to pull the latest code from origin’s master branch and merge those changes into our current branch.

A

git pull origin master