Learning Git Part 2 Flashcards

Starting at Ch7

1
Q

What is the command:

git push
A

Upload data to a remote repository.

A remote repository is the repository that is not a local repository (on your computer). A remote repository is like the Github server.

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

Starting from your local repository, how do you turn that into a remote repository?

A

Follow these steps:
1. Create a local repository using

git init
. You also need to make at least 1 commit.
2. Create a remote repository on a hosting service (Github)
3. You may upload data from the local repository to the remote repository
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Starting from a remote repository, how do you work on a Git project?

A

Follow these steps:
1. Find or create a remote repository
2. Clone (copy) the remote repository to your computer, which will create a local repository
3. Work with local and remote repositories by uploading data back to remote repository.

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

Why do we use remote repositories?

A
  1. Easily back up your project somewhere other than your computer
  2. Access a Git project from multiple computers
  3. Collaborate with others on Git projects
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the steps to create a remote repository and upload some data to it?

A
  1. Create the repository on the hosting service
  2. Add a connection to the remote repository in the local repository
  3. Upload (or push) data from the local repository to the remote repository
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you add a connection to the remote repository?

A

A local repository can communicate w/a remote repository when the local repository has a connection to the remote repository stored within it. This connection will have a name, which we will call remote repository shortname or just shortname.

You must explicitly link the URL of the Github repository to the shortname value you selected by using this command:
~~~
git remote add <shortname> <URL>
~~~
Add a connection to a remote repository named *shortname* at *URL*</URL></shortname>

Once a connection to a remote repository is stored in a local repository, you are able to connect to the remote repository by referring to the shortname rather than the URL in the command line.

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

What happens when you clone a remote repository to create a local repository?

A

Git automatically adds a connection to the remote repository with the default shortname

origin
.

There is nothing special about the name “origin”, it’s just convention.

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

Explain the following commands:

git remote

```
git remote -v
~~~

A

git remote: List the remote repository connections stored in the local repository by shortname

git remote -v: List the remote repository connections in the local repository with shortnames and URLs.

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

What is a remote branch?

A

When you push a local branch to a remote repository, you will create a remote branch. A remote branch is a branch in a remote repository.

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

Do remote branches automatically update when you make more commits on local branches?

A

No. You have to explicitly push commits from a local branch to a remote branch. Every remote branch (that a local repository knows about) also has a remote-tracking branch. This is a reference in a local repository to the commit a remote branch pointed at the last time any network communication happned with the remote repository. You can think of it as being like a bookmark.

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

What is an upstream branch?

A

You can set up a tracking relationship between a local branch and a remote branch by defining which remote branch a local branch should track. This is referred to as the upstream branch.

There are some cases where Git will set the upstream branch automatically, but in other cases you have to set it explicitly.

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

What does Git need to know when you push work from a local branch to a remote branch?

A

When you push work from a local branch to a remote branch, Git needs to know which remote branch you want to push to. If the local branch has an upstream branch defined for it, you can use

git push
with no arguments, and Git will automatically push the work to that branch.

However, if no upstream branch is defined for the local branch you’re working on, you’ll need to specify which remote branch to push to when you enter the

git push
command (if you don’t, you get an error message).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the following command

git push <shortname> <branch_name>
A

Upload content from branch_name to the shortname remote repository

After you execute the

git push
command, two things will happen:
1. A remote branch will be created in the remote repository
2. A remote-tracking branch will be created in your local repository
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the following command:

girt branch --all
A

List local branches and remote-tracking branches

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