Git Flashcards

1
Q

What is Git?

A

A distributed open-source version control system. You can work locally, then share or push your changes to a server (ex. GitHub or Gitlab)

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

main

A

the primary branch of all repositories.

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

branch

A

a version of the repository that diverges from the main working project. Branches can be a new version of a repo, experimental changes, or personal forks of a repository for users to alter and test changes.

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

fork

A

creates a copy of a repository.

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

merge

A

taking the changes from one branch and adding them into another.

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

“git clone LINK-HERE”

A

download an existing git repository to work on locally. git will download the entire repository (files and history). This only needs to be run once per repository since it creates a complete copy on your local machine.

Take the link from a remote repository (HTTPS). Then follow the flashcard “How to start a react repository?”

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

stage

A

you have marked a modified file in its current version to go into your next commit snapshot.

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

git add (command)

A

adds a change in the working directory to the staging area.

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

git commit -m “MESSAGE HERE” (command)

A

used to save your changes to the local repository. You normally want to group

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

git push (command)

A

updates a remote branch with local commits. the “-u” flag links the local branch with the remote branch, so the next time you can just use git push or pull without any arguments.

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

git status (command)

A

displays the state of the working directory and the staging area.

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

staging vs committing

A

The staging environment is where related modified files are added to a queue to be committed later. Committing captures a snapshot of the project’s currently staged changes. You want to stage related changes and then use commit to record those small changes. See the link for example: https://githowto.com/staging_and_committing

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

git pull

A

When you want to take changes or updates done by other developer/team member on git repository. “Git pull” fetches downloads the content from a remote repository and immediately updates the local repository/branch to match the content. In actuality, it is a combination of git fetch and git merge called in that order.

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

“git switch” (command)

A

switch between branches created by git branch. You can also use git checkout to switch branches.

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

“git log” (command)

A

View the history of committed changes within a git repository. To exit git log, type “q” or “z”. Type “h” to seek for help.

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

“git restore –staged FILE-NAME…” (command)

A

unstages the file.

17
Q

“Head” branch

A

the currently “active” or “checked out” branch. Using “git status” will say what head branch- such as On branch …

18
Q

About Branch

A

you can create branches on your local repository and then upload the branch onto a remote repository.

19
Q

“git branch -m NEW-NAME” (command)

A

re-names the local head branch

20
Q

“git branch” (command)

A

shows all branches. Adding BRANCH-NAME right after creates a new branch. To delete a local branch: “git branch -d BRANCH-NAME”. You cannot delete a branch if it is the HEAD branch. To delete a branch in a remote repo “git push REMOTE-NAME –delete BRANCH-NAME”. The remote name is typically origin. You can delete the local and then remote branch.

21
Q

“git branch -m OLD-NAME NEW-NAME”

A

renames a local branch.

22
Q

How to rename branches

A

You can rename branches in remote repositories. So you’ll need to delete the remote current/old branch by “git push origin –delete OLD-NAME” and then push the new local branch with the new name by “git push -u origin NEW-NAME”

23
Q

Should I manage my repository remotely or locally?

A

You should manage your repository and branches locally. First, you should create a local repository and then publish it to the remote repository by “git push -u origin LOCAL-BRANCH”

24
Q

Learn git branching

A

https://learngitbranching.js.org/?locale=en_US AND https://www.youtube.com/watch?v=e2IbNHi4uCI (git branch and merge)

25
Q

merging branches

A

merges changes from another branch into your current local HEAD branch. 1. switch to the branch that should receive the changes using “git switch BRANCH-NAME”. 2. execute the merge command with the name of the branch that contains the desired changes using “git merge BRANCH-NAME”.

26
Q

rebase branches

A

an alternative way to merging. The end result is the same, but the commit history will look like a straight line with no branches. 1. check out the branch that should receive the changes by “git switch BRANCH-NAME”. 2. execute the “rebase” command with the name of the branch that contains the desired changes using “get rebase BRANCH-NAME”

27
Q

comparing branches

A

checks which commits are in branch-B but not in branch-A. Use “git log BRANCH-A BRANCH-B”. You can also compare remote branches to local branches.

28
Q

git checkout

A

lets you switch between branches created by git branch. using “git checkout -b NEW-BRANCH” simultaneously creates a new branch and switches to the new branch

29
Q

How to start a react repository?

A

in terminal, navigate to the directory and run “npm install” then “npm start”

30
Q

git config -l

A

shows the git configuration list with the global user.name and user.email. use keys “j” or “k” to go up or down the list. Use “q” to quit the list.

31
Q

SSH key

A

SSH keys are used for authenticating to a remote server, instead of authenticating using credentials. After generating an SSH key, the private and public keys will have the same name. The .pub file is the public key. In windows the SSH keys are normally stored in C:\Users\USERNAME.ssh

32
Q

local repository name vs remote repository name

A

the local repo directory can be named different than the remote repo and still sync.

33
Q

“git remote set-url origin REMOTE_URL”

A

Changes the URL of the remote origin.

34
Q

how to push new Git branches to a remote repository

A

https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/git-push-new-branch-remote-github-gitlab-upstream-example

35
Q

README.md cheatsheet

A

https://www.markdownguide.org/cheat-sheet/

36
Q

upstream and downstream

A

upstream is the repository that we clone or pull from, or push to. Downstream is our local repository. These terms are relative, which means there is no central upstream or downstream. It depends on what the other repository is trying to do.

37
Q

git fetch

A

This will download all the new changes from the remote repository but will not merge those changes into your local repository. This allows you to review the changes before merging (using “git merge”) them into your local repository.

38
Q

git merge

A

This will merge the changes from “git fetch” into your local repository.

39
Q

“git config –get remote.origin.url”

A

see remote git repository link