简体   繁体   中英

Git bare created on my server, do I clone the repo or do a remote add?

I have a private git setup on my server that is only accessible via SSH.

So I did a git init --bare on my server, now on my laptop how do I reference it?

Do I use a git clone or something else?

Jordan's answer (clone the empty bare repository) is already acccepted, but it's not the only possibility.

If you've already done some work locally (created a repository and committed to it), then you'll use a remote, as mentioned in the question title:

git remote add origin <ssh-url>

since you want to push the work you've already done! You might also want to set your master up to track the remote's master, to make it look more like you cloned from that remote (as if it were the central authoritative source, which it sounds like it is):

git branch --set-upstream master origin/master

That'll let you do things like git pull to implicitly mean git pull origin master .

More or less, ya. It'll show up as an empty repo on the first git clone. You'll have to do a "git push origin master" from your cloned repo before any other git pushes will work.

git clone ssh://username@your-ssh-host/your-repo-location
cd $your_repo
touch Readme
git add Readme
git commit -am "Initial commit"
git push origin master

Hooray!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM