Git and GitHub Flashcards
What is the power of Git?
Version control, it allows us to keep track of the changes that have been made to our projects, to roll back to previous versions and current versions, and to add new features to our projects without have to change its current status.
What are the only two configuration values after you have installed git?
git config –global user.name “Your Name”
git config –global user.email your_name@example.com
to confirm: git config –global –list
What is the color coded output config?
git config –global color.ui “auto”
git init
initialize the repository
git add
add all the files that were changed since the last back up to the staging area
git status
shows you all the files that were changed since the last backup and which ones are already added to the staging area
git commit -m ‘…’
commits the changes to the repository
git checkout ____
switches to the branch name provided in your git repository. This will create a new branch if the name provided doesn’t exist.
git branch
shows all of your git branches and marks the one you are currently on
git log
shows all the backups created in the repository
git blame ___
shows who wrote which line of code or in other words who is to be blamed for that particular line of code
git remote add origin ___
tells git to add a remote place called ‘origin’ to a remote URL ____
git push
pushes the changes in your local repository to the remote repository
git pull
pulls the changes in a remote repository to your own local repository
git clone ___
clones a remote repository in ___ to your own local folder
In our commit log what is the number after the commit text?
It is the commit hash and it’s what we use to refer to a particular commit
git diff –stat ____
git diff prints some statistics about the changes that have been made. Just ad the –stat option to see what changes have been made since a particular commit.
git revert
reverts a commit by creating a commit in your repository that reverses all the changes made by the original commit
Git States
Git has three main states that your files can reside in: committed, modified, and staged.
Modified State
You have changed the file in your Working Directory but have not added it yet.
Staged State
You have marked a modified file to go into the Staging Area for your next commit
Committed
Data is safely stored from the Staging Area into your local .git Directory
Add
Add: In Git, an add is what tells your repository, “Hey, I want you to add these changes to the next version of the project!” You add files to the staging area to have them included in your next commit (see below). If you add a file and then make more changes to it, you must re-add the file to include all of your recent changes.
git add index.html
to add a specific file, indelx.thml to the staging area
git add .
to add all changed files to the staging area
Commit
Commit: Once you feel your project has reached a point where it should be saved, you tell Git to commit all your files in the staging area. This means every file you have added will be updated with the changes you have made. With every commit, you create another local version of your project. Additionally, Git clears the staging area each time you do a commit.
git commit -m ‘Name to identify commit goes here’