简体   繁体   English

将本地 git 存储库导入远程服务器存储库

[英]import local git repo to remote server repo

Update - known issue with git-enterprise.更新 - git-enterprise 的已知问题。 Used unfuddle and subtree merge works now现在使用的 unfuddle 和子树合并工作

I've been developing locally only on my machine using Git.我一直在使用 Git 在我的机器上进行本地开发。 It has never been pushed to a remote repo.它从未被推送到远程仓库。

I just signed up for an account on enterprise git.我刚刚在企业 git 上注册了一个帐户。 I now want to import my local repo to the newly created remote git repo and maintain the history.我现在想将我的本地存储库导入新创建的远程 git 存储库并维护历史记录。

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当我收到 git 提交时

On branch master
nothing to commit (working directory clean)

Doing git push receive做 git 推收

Everything up-to-date

Though if I do "ls" I see all my files.虽然如果我执行“ls”,我会看到我所有的文件。 If I do "git log" I see my version history.如果我执行“git log”,我会看到我的版本历史记录。

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 .以防万一有人在您还负责远程服务器时寻找解决方案:使用git init --bare而不是git init 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).将企业 git 作为远程添加到您现有的本地存储库(其中包含所有数据)。
  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.然后git push <enterprise-remote-name> <branch-name>会将本地仓库中的指定分支推送到企业仓库,并将其所有提交历史记录。

I haven't used enterprise git, but I use github everyday and the above two steps will do what you are looking for.我没有使用企业 git,但我每天都使用 github,以上两个步骤将满足您的需求。

Switched to github and bitbucket private repo.切换到 github 和 bitbucket 私人仓库。 enterprise-git too buggy at least when I was trying至少在我尝试的时候,enterprise-git 太错误了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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