How to use Git Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is Git

A

Git is a version control system.

Git helps you keep track of code changes.

Git is used to collaborate on code.

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

Check what version of Git you are using

A

git –version

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

What does Git do

A

-Manage projects with Repositories
-Clone a project to work on a local copy
-Control and track changes with Staging and Committing
-Branch and Merge to allow for work on different parts and versions of a project
-Pull the latest version of the project to a local copy
-Push local updates to the main project

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

How do you work with Git

A

-Initialize Git on a folder, making it a Repository
- Git now creates a hidden folder to keep track of changes in that folder
When a file is changed, added or deleted, it is considered modified
-You select the modified files you want to Stage
-The Staged files are Committed, which prompts Git to store a permanent snapshot of the files
-Git allows you to see the full history of every commit.
-You can revert back to any previous commit.
-Git does not store a separate copy of every file in every commit, but keeps track of changes made in each commit!

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

Why do you use Git?

A

-Over 70% of developers use Git!
Developers can work together from anywhere in the world.
- Developers can see the full history of the project.
- Developers can revert to earlier versions of a project.

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

Creating Git Folder

A

mkdir myproject
cd myproject

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

Initialize Git

A

git init
Initialized empty Git repository in /Users/user/myproject/.git/

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

Git Adding New Files

A

git status
On branch master

No commits yet

Untracked files:
(use “git add …” to include in what will be committed)
index.html

nothing added to commit but untracked files present (use “git add

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

When to do a Git Staging Environment

A

As you are working, you may be adding, editing and removing files. But whenever you hit a milestone or finish a part of the work, you should add the files to a Staging Environment.

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

What is a staged file

A

Staged files are files that are ready to be committed to the repository you are working on.

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

Add file to the Staging Environment

A

git add index.html

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

How to check if a file is staged

A

git status

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

How to add all files to be staged

A

git add –all

Shortcut: git add -A

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

What is git commit

A

Adding commits keep track of our progress and changes as we work. Git considers each commit change point or “save point”. It is a point in the project you can go back to if you find a bug, or want to make a change.

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

How to do git commit?

A

When we commit, we should always include a message.

Code
git commit -m “First release of Hello World!”
[master (root-commit) 221ec6e] First release of Hello World!
3 files changed, 26 insertions(+)
create mode 100644 README.md
create mode 100644 bluestyle.css
create mode 100644 index.html

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

Why add a git commit message?

A

By adding clear messages to each commit, it is easy for yourself (and others) to see what has changed and when.

17
Q

Git Push

A

git push <folderuwannaupload> main</folderuwannaupload>

make sure you cd .. so your not in the folder you wanna upload

18
Q

How to view a history of commits

A

To view the history of commits for a repository

19
Q

Git Commit without Stage

A

git status –short

then

git commit -a -m “message”

20
Q

How to get Git Help

A

git command -help

See all the available options for the specific command

or

git help –all - See all possible commands

21
Q

What is a Git Branch

A

is a new/separate version of the main repository.

22
Q

How do you create a new branch

A

git branch hello-world-images

(Now we created a new branch called “hello-world-images”)

23
Q

How do you check you created the branch

A

git branch
hello-world-images
* master

(We can see the new branch with the name “hello-world-images”, but the * beside master specifies that we are currently on that branch.)

24
Q

What is Checkout

A

checkout is the command used to check out a branch. Moving us from the current branch, to the one specified at the end of the command:

25
Q

How do you move to the branch you want

A

git checkout hello-world-images
Switched to branch ‘hello-world-images’

26
Q

check the status of the current branch:

A

git status

27
Q

How to add your changes

A

git commit -m “Added image to Hello World”

28
Q

How to merge branches

A
  • Make sure you are on the branch you want to merge to be on
    -git add –all
    git commit -m “added new image”

Move to the master branch
git checkout master
& merge
git merge hello-world-images

29
Q

Git Ignore

A

https://www.freecodecamp.org/news/gitignore-file-how-to-ignore-files-and-folders-in-git/#create

30
Q

requirments.txt

A

pip freeze > requirements.txt