Setting Up Your Environment For Git Interacting With Your Local Git Repo
Setting Up Your Environment For Git Interacting With Your Local Git Repo
Git Setup
Setup properties globally
$git config --global user.name Kalman Hazins
$git config --global user.email [email protected]
Git Setup
Verify that an option has been set
$git config <option>
For example, $git config user.name
Initializing a Repo
Where do I get a repo from?
1. Create a new repo
$cd workding_dir
$git init
(Possibly create a .gitignore file)
$git add .
(. Adds the entire current directory with subdirectories)
Cloning a Repository
2. Clone an existing repo (for example from Github)
$git clone https://repourl.git
Many transfer protocols available
https:
git:
git status
$git status
Provides the current status of your repo
git add
$git add <file/dir>
Add untracked file(s) to be tracked or
Add a modified tracked file to the staging area
Mods made to the file after git add need to be gitadded again even if you did not commit yet
git diff
$git diff
Shows the difference between staging and working
directory
git commit
$git commit
Commits your changes to the repo
Prompts for a commit message in an editor
After committing
$git revert HEAD
Reverts the most recent commit
Summary
You have to add a file for tracking at least once before it
can make it into the repo
Can easily go back in time to a snapshot
Whats next?
Github and remote repositories in Git