Git Flashcards

1
Q

git init

A

initializes git repository -> creates a special folder to hold all of your snapshots (commits) of code

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

command to show all files, including hidden ones

A

ls -la

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

git add

A

adds files to staging area so that we can later take a snapshot of all these changes and save to the repository

example:
git add index.html -> adds that file to staging area
git add *.html -> adds any file that ends in .html

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

git add .

A

every file within folder gets added to the staging area

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

git status

A

shows you everything in staging area (waiting to be saved in to snapshot)

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

git commit

git commit -m “text”

A

commits all the files in staging area -> saves them to original repository that was created

-m lets you add special message,
if you DONT use -m you will go in to a text editor with the assumption you want to create a longer commit

if youre in VIM: type i (allows you to insert); after typing commit; to leave escape -> type :wq -> enter

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

git remove …..

A

possible to remove things from staging area (didnt get full command)

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

git branch -M main

A

changes name of staging area to main (instead of master) -> based on movement to move away from “master” hierarchy

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

What should you do if you want to make some majorrr changes to your code that would likely mess everything up?

A

create a new branch. you can use git status to see what you’re currently on.

git branch / git branch “risky”
git checkout / git checkout “risky”
git status

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

git branch branchName

git checkout branchName

A

creates another branch; takes you to the branch

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

git merge branchName

A

add changes from another branch to Main

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

github

A

using just git saves things locally. but we can save git repositories to the cloud (remote backup) through github

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

how to push code to the cloud (github)

A

go to github; there’s a plus sign -> “create new repository”

git remote -> sets up where remote code gets sent to

git push -u origin main… ->

host code….

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