Git and Github Flashcards

1
Q

git config –global user.name “[name]”

A

This command sets the author name and email address respectively to be used with your commits.

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

git init [repository name]

A

This command is used to start a new repository.

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

git clone [url]

A

This command is used to obtain a repository from an existing URL.

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

git add [file]

A

This command adds a file to the staging area.

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

git add *

A

This command adds one or more to the staging area.

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

git commit -m “[ Type in the commit message]”

A

This command records or snapshots the file permanently in the version history.

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

git commit -a

A

This command commits any files you’ve added with the git add command and also commits any files you’ve changed since then.

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

git diff

A

This command shows the file differences which are not yet staged.

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

git diff –staged

A

This command shows the differences between the files in the staging area and the latest version present.

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

git diff [first branch] [second branch]

A

This command shows the differences between the two branches mentioned.

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

git reset [file]

A

This command unstages the file, but it preserves the file contents.

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

git status

A

This command lists all the files that have to be committed.

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

git log

A

This command is used to list the version history for the current branch.

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

git branch

A

This command lists all the local branches in the current repository.

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

git branch [branch name]

A

This command creates a new branch.

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

git branch -d [branch name]

A

This command deletes the feature branch.

17
Q

git checkout [branch name]

A

This command is used to switch from one branch to another.

18
Q

git merge [branch name]

A

This command merges the specified branch’s history into the current branch.

19
Q

git push [variable name] master

A

This command sends the committed changes of master branch to your remote repository.

20
Q

git pull [Repository Link]

A

This command fetches and merges changes on the remote server to your working directory.

21
Q

Contribute to an existing repository

A

change into the repo directory

git clone https://github.com/owner/repo.git

cd repo

git branch my-branch

git checkout my-branch

git add file1.md file2.md

git commit -m “my snapshot”

git push –set-upstream origin my-branch

22
Q

Start a new repository and publish it to GitHub

A

create a new directory, and initialize it with git-specific functions

git init my-repo

cd my-repo

touch README.md

git add README.md

git commit -m “add README to initial commit”

git remote add origin https://github.com/YOUR-USERNAME/YOUR-REPOSITORY-NAME.git

git push –set-upstream origin main

23
Q

How To Push Git Branch To Remote

A

$ git pull

$ git checkout my-feature

$ git merge origin/feature

$ git push origin my-feature:feature