简体   繁体   中英

import local git repo to remote server repo

Update - known issue with git-enterprise. Used unfuddle and subtree merge works now

I've been developing locally only on my machine using Git. It has never been pushed to a remote repo.

I just signed up for an account on enterprise git. I now want to import my local repo to the newly created remote git repo and maintain the history.

Tried to follow the answer here , though receive

remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error: 
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.

So then tried

git clone repourl/project.git
cd project
git remote add other /tmp/myproject
git checkout master
git commit
git push

When I did git commit received

On branch master
nothing to commit (working directory clean)

Doing git push receive

Everything up-to-date

Though if I do "ls" I see all my files. If I do "git log" I see my version history.

Just in case someone looks for a solution when you're also in charge of the remote server: Init the server's repository with git init --bare instead of just git init .

Wouldn't a simple push do the job?

Here is what I think is needed:

  1. Add the enterprise git as a remote to your existing local repo(which has all the data).
  2. Then a git push <enterprise-remote-name> <branch-name> will push the specified branch on your local repo to the enterprise repo, will all it's commit history.

I haven't used enterprise git, but I use github everyday and the above two steps will do what you are looking for.

Switched to github and bitbucket private repo. enterprise-git too buggy at least when I was trying

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