git Flashcards
git init
initializes a git repository
creates a .git directory, which if deleted will remove the git tracking
/etc/gitconfig
~/.gitconfig
REPOSITORY/.git/config
Git configuration files.
/etc/gitconfig = system wide, applicable to all users
~/.gitconfig = user specific
REPOSITORY/.git/config = repository specific
git config –global user.name “Maya Angelou”
Sets a user.name variable in gitconfig
git config –system sets variables in system gitconfig
git config without flags sets variables in the repository gitconfig
git status
displays the working tree and staging area.
Working tree = files that will be in next submit
staging area = files not impacted by a submit
.gitignore
tells git which files / directories to ignore
e.g. will do as comment indicates:
# Ignore all SQLite databases
db/*.sqlite3
git add
Add a file to git for tracking. Changes made after git add will not be included in a commit
Prior to adding, the file is untracked, and changes can still be made as part of current revision
git commit
a bundle or group of changes which are posted back to main branch.
Can contain multiple files, including new files, and deletion of existing files.
-m flag allows addition of message to the commit
git log
displays a history of commits
branch
copy of all the files in the codebase.
Each branch has an identifying name, and seter of version of commit history
A branch is made by forking
branch commits (not files!) can be merged back into main branch
git fetch
pulls all changes from github down to local git repository
git push
“push” a local git repository to github to track
use “git push -u origin main” to push setting the default upstream repository for push / pull, etc.
sets the “main” branch in the “origin” repository
git diff
used to compare remot to local repositories. use git diff main origin/main or git diff origin/main main
git pull
used to pull changes in local repository from remote
git pull –ff-only
git clone
makes exact copy of remote repository to new local repository