Last active
December 17, 2015 04:18
-
-
Save snorrewb/5549095 to your computer and use it in GitHub Desktop.
Git commands so I don't forget them. Only *.java for syntax highlighting.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// never use GitHub for Windows if you want to avoid losing all your code and most of your hair | |
// setup | |
git init // initialize folder for git repo | |
git remote add origin [email protected]:username/reponame.git // add repo to track | |
git branch -u origin/master // set upstream to origin master (no more "origin master" required after git pull/push | |
// alternatively | |
git push --set-upstream origin master | |
// check status of local repo | |
git status | |
// pull newest files from repo | |
git pull | |
git pull origin/master master // to pull from master branch if upstream isn't set | |
// committing and pushing files | |
git add . // add all the things | |
git commit -a // commit all changes | |
git commit -m "commit message here" // commit with short commit message | |
git commit -am "commit message here" // commit all changes with short commit message | |
git push | |
git push origin master // to push to master branch if upstream isn't set | |
// reset | |
git reset --hard // hard reset of git repo if you really screwed up | |
// create a new branch | |
git checkout --orphan NEWBRANCH // create a new branch called NEWBRANCH | |
git rm -rf // deletes all files in working folder | |
// move between branches (deletes local content maybe?) | |
git checkout master // move to the master branch | |
git checkout NEWBRANCH // move to NEWBRANCH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment