Commands Flashcards

(35 cards)

1
Q

Configure your username and email

A

git config –global user.name “Your name”

git config –global user.email “yourname@provider.com”

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

View git configurations

A

git config –list

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

How to initialize a repository

A

Create a folder and repository on GitHub and open the folder in the Terminal and use the command “git init”

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

instruct Git to link it with the remote repository

A

git remote add origin repo-url

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

If your remote repository already contains some code files, then you need to pull them inside your local repository

A

git pull

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

git init + git remote add origin repo-url + git pull

A

git clone repo-url [folder]

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

verify if a local repository is tracking the remote repository

A

git remote -v

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

replace the remote url

A

git remote set-url origin repo-url

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

This file contains files and folder names that should be ignored by Git while making commits.

A

.gitignore

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

move these files to the staging area

A

git add . || git add [filename] || git add -A || git add *

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

If you added some files in the staging area by mistake, then you can use the following command to unstage them

A

git reset [filename]

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

To create a commit, use the following command.

A

git commit -m “initial commit”

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

flag is used to insert a message that will describe the commit.

A

-m

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

All files shows _____ mode which means there are all new file.

A

create

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

To see all the commits in the repository (made by all the developers), use following command.

A

git log

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

To see file that was changed or added in a commit

A

git log –stat

17
Q

To change the message of the previous commit

A

git commit –amend -m “Initial Commit”

18
Q

You can avoid edit message dialog

A

git commit –amend –no-edit

19
Q

to write and exit the vim editor

20
Q

push that commit to the remote repository.

A

git push -u origin master

21
Q

forget if commits after that ever existed

A

git reset –soft #
git reset –mixed #
git reset –hard #

22
Q

You can use git ____ to see what code changes between the current state of the files and the state of the files in the previous commit.

23
Q

will set state of the above file to state of file in HEAD commit

A

git checkout – [filename]

24
Q

If you have lots of untracked files or folders in the repository which you want to remove

A

git clean -f -d

25
create a branch with the name
git branch git branch [name] git checkout [branch name]
26
To check all local and remote branches
git branch -a
27
to update your remote-tracking branches
git fetch
28
If a remote branch already exists with a different name than you want to track with the current branch, then use command
git branch --set-upstream-to origin/dev_uday
29
command will create [branch name] branch on remote repository and our local branch will track it
git push -u origin [branch name]
30
switch to master [Head]
git checkout master
31
we must pull code from the remote repository before doing anything, always do this.
git pull | git branch --merged
32
following command will merge the branch with the current branch.
git merge [branch name]
33
verify merger by executing
git branch --merged
34
If we are done with branch and we don’t need it anymore, then we can just delete it using the command below. This will delete local branch only.
git branch -d [branch name]
35
To delete remote dev branch as well, you need to use the command
git push --delete origin [branch name]