-
-
Save jamesmichiemo/4631573 to your computer and use it in GitHub Desktop.
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
//Git Commands | |
# NOTES: Lines starting with // or # are comments and should not be typed into terminal. Please be careful of your spelling, spacing, and case before initiating a command in terminal. | |
//Standards Commands to push to github (in order) | |
git add . | |
# adds all files and folders that contain files to be commited | |
git status | |
# shows what changes are going to be commited | |
git commit -m 'Some descriptive commit message' | |
# commits all added items to the staging area with the included commit message | |
git push origin master | |
# pushes or 'syncs' your local git repo, origin, with the github.com master repo | |
//Standard Commands to copy origin to gh-pages | |
git checkout gh-pages | |
# Change to the gh-pages branch | |
git merge master | |
# bring gh-pages up to date with master | |
git push origin gh-pages | |
# push the changes to the server's gh-pages branch | |
git checkout master | |
# return to the master branch | |
//Alternate way to copy master to gh-pages | |
git checkout gh-pages | |
# Change to the gh-pages branch | |
git rebase master | |
# bring gh-pages up to date with master (The difference here is that rebase is copying all commits from master and overriding them on gh-pages) | |
git push origin gh-pages | |
# push the changes to the server's gh-pages branch | |
git checkout master | |
# return to the master branch | |
//Misc Commands | |
git branch gh-pages // creates a gh-pages branch locally | |
Setting up a New Repo | |
------------------------ | |
cd /path/to/folder/of/your/files/ | |
# change terminal's directory to that of your local repository folder | |
git init | |
# initialize git. This creates a hidden .git folder in the current location | |
git add . | |
# adds all files and folders in the current directory to the commit list | |
git commit -m 'first commit of new files' | |
# commits all added files and includes the desired commit message | |
git remote add origin [email protected]:YOURUSERNAME/THENAMEOFYOURREPO.git | |
# links your local repo with the desired github repo. Replace this URL with the one given to you on your repo page. If done correctly you will never need to do this again for the current folder. | |
git push -u origin master | |
# Pushes the local files to the server | |
//Changing the remote url: this is used when you need to change the connection between a local repo and the server. | |
git remote -v | |
# View existing remotes | |
# origin https://github.com/user/repo.git (fetch) | |
# origin https://github.com/user/repo.git (push) | |
git remote set-url origin https://github.com/user/repo2.git | |
# Change the 'origin' remote's URL | |
git remote -v | |
# Verify new remote URL | |
# origin https://github.com/user/repo2.git (fetch) | |
# origin https://github.com/user/repo2.git (push) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment