Git Cheats

Go to your directory where you want to your own local repository

cd ~/
mkdir newreponame

Add “Read Me” file that describes your code

echo "# Learning Git" >> README.md

Intialize Git

git init

Add “Read Me” file

git add README.md

Mark all of your current files to be pushed to the staging area

git add *

Show changes betwen working directory and staging area

git diff <file>

Add your Commit message

git commit -m "my first commit"

Add the remote Origin repo

git remote add origin https://gitsomewhere/username/nameofrepo.git

Check remote origins that are configured

git remote -v

Delete origin if needed

git remove rm origin

Configure Global Variables

git config --global user.email "your.email@email.com"
git config --global user.name "git-repo username"

Pull files down to local repo for the latest

git pull

Push all local files

git push

Make some changes to your local files, commit and push again

git commit -a -m "updated README file"
git push

Rename Git branch

git branch -m old_name new_name
git push origin :old_name
git push --set-upstream origin new_name

Display the status of the working directory

git status

Reset a file from respository to a previous known working state

git reset <file>