Git Flashcards
How do you create a new branch and switch to it in Git?
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
What does git init do?
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.
What does git status do?
It lets you see which changes have been staged, which haven’t, and which files aren’t being tracked by Git.
What does git diff do?
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.
What is the difference between:
git add .
git add –all
git add -A
git add -u
git add –update
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 do you make it so you don’t have to keep re-entering your credentials when pushing/pulling to git?
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.