Uncut Daily

Git Commands Cheat Sheet, Daily Workflow in 1 hour

git
Git Version Control

Common Command Line Commands:

pwd – point where you currently are in your directory
mkdir "name"
– create a folder
cd
– change directory
touch "file name.extension"
– create a file

Git, Getting Setup

Check first to see if it is installed on computer and check your config list:

git --version
git config --list

When first starting out on any computer run these commands to set up your list:

git config --global user.name "Your name here"
git config --global user.email "Your email you use for GitHub here"

When you are in the master branch of your new repository folder, right click and use “Git Bash here” , then run:

git init

This will tell Git to start keeping track of any changes that happen inside that folder.

git status
git add "name of folder" or "name of file"
git status
git commit -m "whatever you did"

Chances are you will have to pull a repository from another GitHub server using:

pwd - see where you are cloning it
git clone "https of that repository"

Switch to the master branch:

git checkout master

Recursively delete a folder:
git rm -r folder name or "folder name"

Delete single file:

git rm file.extention
git commit -m "deleted file"
git push origin master

When on GitHub, always use dashes for name, even when you are creating a folder on your local computer use dashes and not spaces. To see where exactly you are pushing too run:

git remote -v
or to set a new places to push run:

git remote add origin "https.."

git remote set-url origin "https.."

Say you made changes to a file and now you’re ready to push:
git status
git add -A
(meaning all files to staging area) or path to file or file.extention) OR
git add . (meaning only the changed files)
git commit -m "added them"
git push origin master

Pulling in the latest changes from the GitHub server if say your partner made changes:

git pull origin master

Recover files from last commit in case they get deleted:

git checkout --.

Working With Branches

Create a new branch:

Leave a Reply

Your email address will not be published. Required fields are marked *