Git Flashcards

1
Q

How do you create a new branch and switch to it in Git?

A

git branch new_branch

“new_branch” is the name of the new branch you want to create. To switch to it:

git checkout new_branch

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

What does git init do?

A

Running “git init” in a folder adds the .git folder, which includes a staging area and history for this current folder. Now we have a working tree (all your files), a staging area, and a history container of all the commits we’re going to make so we can jump between versions as we please.

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

What does git status do?

A

It lets you see which changes have been staged, which haven’t, and which files aren’t being tracked by Git.

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

What does git diff do?

A

git diff is used to see the difference between tracked files in the working tree and the staging area. This happens if you add a file using git add and then make a change to it afterward.

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

What is the difference between:

git add .
git add –all
git add -A
git add -u
git add –update

A

git add .

adds all NEW files and changes to existing files to the staging area

git add -u
or
git add –update

adds changes to existing files and DELETED files to the staging area

git add –all
and
git add -A

are the same. They add NEW files, changes to existing files, and DELETED files to the staging area. Its like doing both git add . and git add -u/–update

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

How do you make it so you don’t have to keep re-entering your credentials when pushing/pulling to git?

A

config –global credential.helper ‘cache –timeout=3600’

This stops them asking for a password every hour. Increase the number to increase the time the password is cached.

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