JoeCortopassi
JoeCortopassi

Reputation: 5093

Having trouble working with a Git repository

Wondering if some one can help me here, I'm having a hard time learning Git.

I have shared hosting that I was able to set up Git on. I've been making commits and everything, and now I want to be able to pull(wrong vocab?) my repo down to my laptop. How do I do this? Whenever I read the examples, /path/to/files confuses me. My files and git repo are on:

http://abc.com/dev/project/

I have ssh access and everything. I have a local repository on my laptop at:

/Users/me/Documents/project/

I guess my main question is this: Can I copy down what's on my host, work on the file on my laptop, commit the changes, then update the server with my changes?

Upvotes: 3

Views: 133

Answers (1)

sehe
sehe

Reputation: 392921

git clone http://abc.com/dev/project/ $HOME/myworkdir
cd $HOME/myworkdir

// edit some stuff

git add . 
git commit -m 'edited some stuff :)'
git push origin

That should normally be the most simple workflow

Update to your comment:

It means that the remote is either a completely new (empty) repository (no harm done) or that it hasn't nominated a current branch. The first thing is fixed by pushing a new branch

cd ~/myworkdir
git commit --allow-empty -am 'initial commit'
git push origin master

If the local repository hasn't been cloned from the remote, you can

git push http://abc.com/dev/project/ master

If the local branch has another name you can use it instead of master, or

git push origin HEAD:master

To push current local HEAD as the new branch master

I recommend re-cloning your repository after the initial commit is in; this way you get the 'conventional' clone setup (with default origin remote and ditto tracking branch on master)

Upvotes: 4

Related Questions