Get a local git repo up on an EC2 Instance.
Add yourself to the ssh auth agent, if you haven't already.
ssh-add path/to/your/EC2.pem
SSH into the remote directory, and create a barebones remote repo directory.
ssh [email protected]
mkdir repo-name.git && cd repo-name.git
git init --bare
cd repo-name
git init git add .
git commit -m "Initial git commit message"
git remote add origin [email protected]:/path/to/your/repo-name.git
git config --global remote.origin.receivepack "git receive-pack" # needed for aws ec2 stuff.
git push origin master
The origin url can be used for cloning too.
git clone [email protected]:/path/to/your/repo-name.git
(This guide was lifted from here, then modified slightly.)
Great post, thanks!!
So I had the same issue as @buckeyja, but I found out why. Basically, if you go to your remote machine, you'll see the BARE git repo. A bare repo doesn't have a "working tree" or something which means all you can do is pull from it. So, in order to see/edit your files on your remote machine, just pull from there.
Example:
Get on your remote machine in the same directory as your .git file and run:
git clone [-b branchName] git@path_to_your_git_repository
Here's a link to the SO answer I found all this out from, give the answer an upvote!! https://stackoverflow.com/questions/1456923/why-am-i-getting-the-message-fatal-this-operation-must-be-run-in-a-work-tree