Last active
December 17, 2015 11:49
-
-
Save kentcdodds/5604822 to your computer and use it in GitHub Desktop.
Git Command Reminder. For all the times I think "how do I do that again?"
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
#Set a new remote origin url | |
git remote set-url origin git://new.url.here | |
#Add an alternate remote: | |
git remote add <remote-name> <url> | |
#Make the server look just like local | |
git push -f <remote> <branch> | |
#Make local look just like the server | |
git fetch --all | |
git reset --hard origin/master | |
################################################## | |
#Make local git repository | |
#First, create the Git repository: | |
mkdir ~/git/repo-name.git | |
cd ~/git/repo-name.git | |
git init --bare . | |
#Then, clone it to a working directory: | |
mkdir ~/projects/repo-name | |
cd ~/projects/repo-name | |
git clone ~/git/repo-name.git/ . | |
#Configure which repository you will push and pull to: | |
git remote rm origin | |
git remote add origin ~/git/repo-name.git | |
git push -u origin master | |
################################################## | |
###################### Stash Stuff ######################### | |
#See all current stashes | |
git stash list | |
#To stash working directory | |
git stash | |
#To apply a stash and remove it from the list | |
# n represents the number of the stash | |
# the "stash@{n}" part is optional. If left out, you'll apply all stashes | |
# to not remove it from the list, use "apply" instead of "pop" | |
git stash pop stash@{n} | |
###################################################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment