Git & GitHub Flashcards

1
Q

What’s a version control system? And how do we classify Git?

A

A VSC is a way of handling with multiple versions of a document, creating a way of ‘time traveling’ through these versions.

GIT is a distributed version control system.

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

What’s the difference between Git and GitHub?

A

Github is just a place where we can store our git repositories.

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

How do you configure your git to add your name and email?

A

git config –system user.name “name of person”

git config –system email@email.com

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

How to initialize a git repo?

A

on the directory you want to version control:

git init

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

What are the 3 stages a file can be?

A

1 - untracked
2 - on stage (goes on the next commit)
3 - commited (ready to push)

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

How do you change branches?

A

git checkout branch_name

or to create and go:

git checkout -b newBranchName

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

How do you list you current branches?

A

git branch

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

How to delete a branch?

A

git branch -D

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

How to see how is the status of your repository?

A

git status

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

How to add a file to the “on stage” state?

A

git add file

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

How to commit a change to the staged files?

A

git commit -m “msg of commit”

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

How to upload your changes to your github repo?

A

git push -u origin master

This pushed your master branch to the remote repo

-u flag sets the upstream so we can use just ‘git push’ after that

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

How to add the URL of the remote repo?

A

git remote add origin “http/ssh url”

“origin” here is the nickname of our repo

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

How to check the current URL of our remote repo?

A

git remote -v

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

How to clone a repo?

A

git clone repo_url

Will create a directory on the pwd that will hold the project cloned

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

How to check the logs of a project? And for a specific file?

A

git log

specific file:
git log file_name

17
Q

How to see the modifications done in a commit? And how to check just the last commit?

A

git show commit_hash

If you do just git show you list just the last commited changes.

18
Q

How to remove/rename/move a file on a git repo? Why?

A

git rm/git mv

We do this because if we do the normal rm/mv way the change will have to be commited to work on the remote repo, this way its done already and the next push will update the remote repo automatically.

And by doing so, if we delete a file we can later recover it.

19
Q

How do you ignore a file/directory to not upload it?

A

Create a .gitignore file on source folder and add the path to the file/directory you want to ignore. ONE PER LINE!

Like
node_modules/
src/passwords/

20
Q

How to remove from the project a file/folder you added but it should be on gitignore?

A

Execute
git rm -r –cached file_name

add them to .gitignore

git add .gitignore

git push

21
Q

How to delete a remote branch?

A

git push origin –delete branchName

22
Q

How to fetch and merge the remote changes to the local project? And if we want to do it separetely?

A

git pull

sep: git fetch + git merge

23
Q

How to do a good Pull Request? (PR)

A
  1. clone project
  2. create your branch
  3. make changes
  4. git push -u origin yourBranchName
  5. On github open the PR and click Compare, making sure you are comparing the master to your branch
  6. Add a descriptive title + description
  7. Make sure to describe each commit you do after that
24
Q

Should we work on the master branch?

A

NOOOOO!!!