Git & GitHub Flashcards

1
Q

What is a branch?

A

Branch: A version of the codebase that diverges from the main branch to isolate changes for specific features, fixes, or experiments.

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

What is a commit?

A

Commit: A snapshot of your changes, saved to your local repository. Each commit is uniquely identified by a checksum.

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

What is the stage?

A

Stage: The area where Git tracks changes that are ready to be included in the next commit. Files in the staging area are prepared (staged) for the next commit.

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

What is a merge?

A

Merge: The process of integrating changes from one branch into another, typically the main branch.

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

What is a Pull Request?

A

Pull Request: A proposal to merge changes from one branch into another, often used in collaborative environments to review and discuss changes before they are merged.

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

What does Fork mean?

A

Fork: A personal copy of someone else’s project that lives on your GitHub account.

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

What does clone mean?

A

Clone: The act of downloading a repository from a remote source to your local machine.

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

what does “remote” mean?

A

Remote: A common repository that all team members use to exchange their changes.

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

what does “origin” mean?

A

Origin: The default name Git gives to the server from which you cloned.

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

What does “upstream” mean?

A

Upstream: The original repository that was cloned.
(or in the direction of the original repository that was cloned.)

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

what is master/main?

A

Master: The default branch name given to a repository when it is created. In modern practice, it is often replaced with “main.”

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

what is a repository?

A

Repository: A storage location where your project lives, containing all the files and revision history.

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

what is the working directory?

A

Working Directory: The directory (folder) on your computer where you are making changes to your project.

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

Staging Area

A

Staging Area: Also known as the “Index,” it’s an area where Git tracks changes that are ready to be committed.

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

Index

A

Index: Another name for the staging area, where Git tracks changes that are ready to be committed.

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

HEAD

A

HEAD: A reference to the last commit in the currently checked-out branch.

17
Q

checkout

A

Checkout: The action of switching from one branch to another or to a specific commit.

18
Q

Push

A

Push: The action of sending your commits to a remote repository.

19
Q

Pull

A

Pull: The action of fetching changes from a remote repository and merging them into your current branch.

20
Q

Fetch

A

Fetch: The action of retrieving updates from a remote repository without merging them into your current branch.

21
Q

How do you Create a remote repository, create a local repository and then connect them?

A

remote repo:
1. go to github.com
2. click on the + (plus) sign
3. It will give you an option to make a new repository
4. It will spit out a HTTP or SSH string that you will use to connect the two repos

local repo:
1.In terminal, go to the folder where you want to create your new repo.
2. type: git init nameOfNewRepo
– this will create a new folder with the name of your repo and inside that folder will be another folder called .git which will contain all the necessary files for your repo. – so it creates a folder to hold everything, you don’t need to do that beforehand
– also, give it the exact same name you gave the remote repo on Github

Connect local and remote repos:
1. Go to Github and copy the HTTP string that was generated when you created the remote repo. (it might be under the CODE button)
2. In the terminal navigate to the folder of your local repo
3. type this command:
git remote add origin HTTPstringOfRemotRepo
4. If you’re not already authenticated, it will ask you for auth - either by password or personal access token (PAT). I used PAT and it lasts for 30 days.
5. to get a PAT click on your avatar pic, go to settings, click on developer settings (bottom of left side bar), personal access tokens (left side bar) and then “tokens classic”

May want to set up SSH in the future.

22
Q

what does the following terminal prompt do?
cd..

A

go up one directory (folder)
so if you’re in
C:/users/stuck you’ll go up one to
C:/users

23
Q

What does this command prompt do?
cd\

A

It takes you to the top of the directory tree
so if you’re in C:\user\stuck\blah
it will take you to
C:\

24
Q

How do you move down into an already established directory?

A

cd plus entire path name
OR
cd nameOfFolder (if folder is just the next step down)

If you know the path to the directory you want, you can type it in using backslashes. For example, this would get you to the desktop
cd C:\Users\stuck\Desktop
if your at desktop ^^ and you want to get into the Bubba folder which is inside desktop you can type
cd Bubba
and that will put you inside the Bubba folder

25
Q

How do you change drives using the terminal/command prompt?

A

To access another drive, type the drive’s letter, followed by :
For instance, if you wanted to change the drive from C: to D:, you should type: d:

26
Q

From the terminal, how do you see what files and folders are in the current directory?

A

DIR

27
Q

from the terminal, how do you make a new directory?

A

mkdir nameOfDirectory
so if I wanted to make a folder called “bubba” I would type
mkdir bubba

28
Q

How do you pull down changes from a remote repository into your local repository?

A

In the terminal:
1. make sure you’re in the directory of you local repo
2. type: git pull origin main

29
Q

how do you check the status of the current branch?

A

git status
it will show the status of the current branch, including any changes that have been made to the files in the repository. It provides information about which files have been modified, which files have been staged, and which files are untracked.

30
Q

How do you add files to the staging area?

A

git add fileName

git add . – I believe this adds everything to the staging area

31
Q

How do you commit changes to the current branch?

A

git commit -m “Commit message”

32
Q

How do you push your changes to a remote repository?

A

git push origin main

33
Q

List all the typical steps you would take when making a commit and pushing to the remote repo?

A
  1. After making your changes, save the file in VSCode – CTRL + S
  2. git status – this will show you in which files there are changes
  3. git add . OR git add fileName – this will add your changes to the staging area
  4. git commit -m “commitMessage” – this will commit those changes
  5. git push origin main – this will push your newly committed changes to the remote repository.
34
Q
A