Git Commands Flashcards

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

What is Git?

A

A version control system
Software that tracks and manages changes to files over time

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

Repository

A

A workspace which tracks and manages files in a folder

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

git status

A

Checks if I’m in a git repo and commits
also can announce if and what file has made changes

working tree clean means it’s up to date

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

git init

A

Initializes empty Git repository in chosen folder (start) - hidden - one per project

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

rm -rf .git

A

This will remove your entire git history for the project

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

git add Chapter1.txt

A

If seen modified we can use add command and group together to get ready to commit
Can be one file or multiple

save point - staging area - stage file to be committed

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

git commit -m “my message”

A

This is like a checkpoint of process of your text/code

This will name the checkpoint easy

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

git log

A

This show a log of the commits for a given repository
This will show the author,date and commit messages

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

git add .

A

This will stage all changes at once which is all files at once being worked on

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

Add what you missed then
git commit - - amend

A

To redo a commit message update if you made a mistake one commit ago

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

touch .gitignore

A

This creates a new file that will hide files or directories to save your hidden codes or and frameworks/libraries

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

git branch

A

List the current branches in the repository

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

git branch bugfix

A

This will create a new branch it can be best to create this in a new folder
~mkdir BugFixes

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

git switch Done or /git checkout

A

This will switch to this branch for the meantime

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

git switch -c Done

A

This will create a new branch and switch over all at once

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

git branch -D Done

A

Must be on a different branch and this will delete a branch

17
Q

git branch -m Main/ git commit -a -m Dn

A

Must be on current branch
This will change the name of the current branch including the default branch

18
Q

git merge bugfix

A

This will merge with another branch

19
Q

git diff

A

List all the changes in the working directory shows the differences in txt/code

20
Q

git stash / git stash save

A

This helps you save changes that you are not yet ready to commit

21
Q

git stash pop

A

To remove the most recently stashed changes

22
Q

git stash apply

A

This will apply whatever is stashed away

23
Q

git restore - - source HEAD~1 app.js

A
24
Q

git reset <commit-hash> /
git reset hard <commit-hash></commit-hash></commit-hash>

A

Reset a repo back to a specific commit

25
Q

git revert

A
26
Q

git - - amend

A

To edit and change last commit message