Git: Setup a remote Git repository

o setup a folder on a server which service for remote Git repository, apply the following steps:

  1. Create a folder on a shared server.
  2. Apply the git command on that folder: git init –bare
  3. Add that folder as the remote repository. In visual studio, it’s quite easily. You enter the ‘name’, ‘path’ in a popup dialog when you adding a remote repository.
  4. That’s not enough yet. You will get a failed message when pushing to the new-added remote repository. The problem here is, the local ‘master’ branch is not tracking the remote ‘master’ branch yet To add such kind of tracking, you need add the following changes manually:
    1. Open .git folder, open the config file (without extension) in the text editor.
    2. Add following codes.
[branch "master"]
    remote = origin
    merge = refs/heads/master

Now, you can enjoy coding with you next setup repository.

是为之记。
Alva Chien
2016.5.23

当在使用git添加远程github仓库时,如果提示"fatal: remote origin already exists"错误,表示已经存在一个名为origin的远程仓库。这通常是因为之前已经添加过一次远程仓库了。为了解决这个问题,你可以尝试以下几种方法: 1. 使用命令"git remote rm origin"来移除已存在的origin远程仓库。然后使用"git remote add origin git@github.com:(github名)/(git项目名).git"来重新添加远程仓库。 2. 如果第一种方法不起作用,你可以尝试在.git/config文件中手动编辑,将已存在的origin删除并重新添加远程仓库。你可以使用文本编辑器打开该文件,查找并删除包含"origin"的部分,然后保存文件。接着使用"git remote add origin git@github.com:(github名)/(git项目名).git"来重新添加远程仓库。 3. 另一种方法是在你的本地.ssh目录中创建一个名为config的文件,并在其中添加以下内容:重新执行"git push -u origin"命令。这将覆盖已存在的origin并重新添加远程仓库。 希望这些方法可以帮助你解决这个问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [git报错:fatal: remote origin already exists](https://blog.csdn.net/gls_nuaa/article/details/121036124)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [Git 提示fatal: remote origin already exists 错误解决办法](https://blog.csdn.net/stange1/article/details/124203887)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [Git常见的报错](https://download.csdn.net/download/weixin_38593723/14037714)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值