Skip to content

Instantly share code, notes, and snippets.

@akinjide

akinjide/git_commands.md

Last active May 11, 2017
Embed
What would you like to do?
GIT COMMAND FUNCTION
git init Make the current folder Git enabled
git config --global user.name "Akinjide Bankole"  Identify yourself for commits
git config --global user.email "r@akinjide.me" Identify yourself for commits (remove --global for a specific project)
git status Show the working tree status (with .git inside)
git add filename.ext Add file to stage
git reset filename.ext Remove file from stage
git rm filename.ext or '*.ext' Remove file from stage and delete
git rm -r directoryname Remove directory from remote
git commit -m "Name of commit" Make a commit with that name
git remote add origin https://github.com/akinjide/repo-name.git   Create an alias for your remote in the repo at this link
git remote set-url origin https://github.com/akinjide/repo-name.git Change repo link for your remote origin
git remote rm origin  Remove the remote origin
git push -u origin master  Regular first time push to remember origin to master
git push --force origin Make it push, bitch!
git push -f origin HEAD^:master Undo a push
git pull origin master  Sync to my local master
git diff HEAD Check what's been removed or added since our last commit(HEAD)
git diff --staged   Check what's been removed or added in our stage
git checkout -- filename.ext   Remove all changes since this file was committed
git branch  See all the branches
git ls-files See all the files
git branch branchname Create new branch
git checkout -b branchname   Switch to branch
git merge branchname   Merge branchname with master(first checkout to master)
git branch -d branchname   Delete branch
git config remote.origin.url Check the current repository link
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.