Git 在目录中发出克隆问题

Git Issue cloning within a directory

我想设置一个本地目录以将新文件修改推送到我的 Bitbucket Git 存储库。我最初使用 Bitbucket 上的在线说明设置了一个目录,但此后将该目录的位置移动到了另一个位置。我现在遇到错误,我一直在尝试设置这个本地目录。

示例:我搬家了

'folder/another_folder/folder_I_want_to_push_updates'

'folder/folder_I_want_to_push_updates'

我尝试了以下命令并得到了这些错误:

cd folder

folder

我有子目录

'folder_I_want_to_push_updates'

等文件夹。我想将文档推送到

中子目录中的 Bitbucket

'folder_I_want_to_push_updates'.

$ git init

Reinitialized existing Git repository in 'folder/folder_I_want_to_push_updates'

$ git clone https://account@bitbucket.org/account/repository.git

存储库与 'subfolder_in_folder_I_want_to_push_updates'

同名

fatal: destination path 'subfolder_in_folder_I_want_to_push_updates' already exists and is not an empty directory.

$ git add .

(无错误)

$ git commit -m subfolder/file.m  

[master 8ac5364] subfolder/file.m Committer: name Your name and email address were configured automatically based on your username and hostname. Please check that they are accurate. You can suppress this message by setting them explicitly. Run the following command and follow the instructions in your editor to edit your configuration file:

git config --global --edit

After doing this, you may fix the identity used for this commit with:

git commit --amend --reset-author

1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test

$git push origin 

warning: push.default is unset; its implicit value has changed in Git 2.0 from 'matching' to 'simple'. To squelch this message and maintain the traditional behavior ........... ........... etc. fatal: The current branch master has no upstream branch. To push the current branch and set the remote as upstream

我想有一个简单的解决方案,但我是 Git 的新手并且正在努力解决它。

有什么方法可以重新开始并删除所有链接并将本地存储库重新配置到 Bitbucket?

您无法克隆到已包含 git 存储库的文件夹中。只需在没有 git init 的情况下执行相同的过程,你应该没问题。确保在完成克隆后添加更新以避免信息丢失。

你当然可以重新来过! 您的本地存储库和远程存储库是相等的(假设您已将所有待处理的提交推送到本地存储库)。

现在删除 link 到您的远程仓库:

git remote rm

现在删除你的本地仓库(最好复制一份),这也意味着删除。git。 关注:How to fully delete a git repository created with init?

现在导航到您想要重新 link 遥控器的新文件夹并按照 bitbucket 说明进行操作或简单地:

git init
git add --all

git commit -m "Initial Commit"

登录到您的 bitbucket 远程仓库:

git remote add origin https://username@your.bitbucket.domain:7999/yourproject/repo.git 
git push -u origin master

这样应该没问题!