Created
November 3, 2017 09:02
-
-
Save Kukunin/20fa8a00d4ab75aa4366cc1f45fcf3b0 to your computer and use it in GitHub Desktop.
How to upload git repo to the server directly without a intermediate repository
This file contains hidden or 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
# We are in a folder with local git repository | |
pwd | |
# We need to create an empty repo on the server | |
# We want to checkout another branch because | |
# git prevents you from pushing to the current checked branch, which is master by default | |
ssh <user>@<host> 'mkdir repo && cd repo && git init && git checkout -b local' | |
# Add remote repo | |
git remote add server <user>@<host>:repo | |
# Push master or whatever you want | |
git push server master | |
# Updates files tree to match your pushed branch | |
ssh <user>@<host> 'cd repo && git reset --hard master' | |
# That's it. You have a copy of git repository on the server without any intermediate repository |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment