git 如何使用sourcetree添加远程存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45091933/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 12:49:32  来源:igfitidea点击:

how to add remote repository using sourcetree

gitbitbucketatlassian-sourcetree

提问by Ezra Bekele

I'm using a Mac and I'm new to bitbucket and sourcetree. I want to push my local repository to a remote repository. So in sourcetree, I pressed "New", "clone from Url" and I pasted the url right from our remote repository. When I press enter, it says the url isn't valid.

我使用的是 Mac,我是 bitbucket 和 sourcetree 的新手。我想将我的本地存储库推送到远程存储库。因此,在 sourcetree 中,我按了“新建”、“从 Url 克隆”,然后直接从我们的远程存储库粘贴了 url。当我按回车键时,它说网址无效。

I kinda rushed through the installation, so maybe that could be it.

我有点匆忙完成安装,所以也许就是这样。

回答by Sahan Serasinghe

I'm assuming your local folder is initialized with git.

我假设你的本地文件夹是用git.

There are two ways you can achieve this:

有两种方法可以实现这一点:

Via Sourcetree app:

通过 Sourcetree 应用程序:

  1. In Sourcetree, check the left pane for Remotes
  1. 在 Sourcetree 中,检查左窗格中的 Remotes

enter image description here

在此处输入图片说明

  1. Right click on it and select New Remote
  1. 右键单击它并选择 New Remote

enter image description here

在此处输入图片说明

  1. Insert the link to your repo and click on OK

  2. Once that's done, just do a Pull from your branch and commit your changes to the repo

  1. 将链接插入到您的存储库中,然后单击“确定”

  2. 完成后,只需从您的分支执行 Pull 并将您的更改提交到 repo

Via Terminal (the easy way)

通过终端(简单的方法)

  1. cd /path/to/your/repo
  2. git remote add origin https://remote_url_of_your_repo
  3. git push -u origin master
  1. cd /path/to/your/repo
  2. git remote add origin https://remote_url_of_your_repo
  3. git push -u origin master

回答by Ezra Bekele

What Sahan said is correct. But what solved my issue was I had to create a folder firstin the remote repository.

萨汗说的是对的。但是解决我的问题的是我必须首先在远程存储库中创建一个文件夹。