Skip to content

Instantly share code, notes, and snippets.

@agalea91
Created June 9, 2016 03:43
Show Gist options
  • Save agalea91/299fd34ec87b99fc00306e082bbfdcbf to your computer and use it in GitHub Desktop.
Save agalea91/299fd34ec87b99fc00306e082bbfdcbf to your computer and use it in GitHub Desktop.
see all available commands:
git
grab a repository from git:
git clone ___url___
> COMMANDS FOR MAKING NEW GIT REPOSITORY
git init
git add -A
git commit -m "First commit"
git remote add origin ___url___
git remote -v
git push origin master
> COMMANDS FOR PUSHING TO ORIGIN FROM MASTER
(origin is the local hard drive and master is github)
to add a file:
git add -A
git commit -m "First commit"
git push origin master
Note: I should do all file deletions
from git shell using: e.g.
git rm -r one-of-the-directories
git commit -m "Remove duplicated directory"
git push origin master
> COMMANDS FOR UPDATING PROJECTS
(must be in repository folder in git shell)
grab a new change:
git pull origin master
check for changes:
git status
add to the project:
git add __filename__
git add -A [adds all files in directory]
commit new additions:
git commit -m "message about the update"
push the commit:
git push origin master
**if conflict, fix then do 1) git add -A 2) git commit 3) -escape- :wq 4) git push**
> COMMANDS FOR UPDATING FORK WITH ORIGINAL (first get forked directory on local)
# Add the remote, call it "upstream":
git remote add upstream ___url___
# Fetch all the branches of that remote into remote-tracking branches,
# such as upstream/master:
git fetch upstream
# Make sure that you're on your master branch:
git checkout master
# Rewrite your master branch so that any commits of yours that
# aren't already in upstream/master are replayed on top of that
# other branch:
git rebase upstream/master
NOTE: If you don't want to rewrite the history of your master branch, (for example because other people may have cloned it) then you should replace the last command with git merge upstream/master. However, for making further pull requests that are as clean as possible, it's probably better to rebase.
> MAKING A BRANCH
# create local branch
git checkout -b __newbranchname__
# swap back to master
git checkout master
# see all branches
git branch
# push new brach to github
git push origin __newbranchname__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment