刚刚在我的电脑上创建了一个Git仓库。如何将回购转到GitHub?

时间:2015-12-05 22:06:36

标签: git github

我是Git的新手。我刚刚在我的计算机上创建了一个Git存储库。现在我想将该存储库连接到网站(GitHub)并将我的代码推送到那里。

我该怎么做?我有点熟悉...我必须以某种方式将在线代码设置为我的电脑版本的上游或下游,然后执行提交或推送或拉到上游或下游在线版本...

我需要用Pycharm推送或拉到GitHub ...... (但是从Git命令行就可以了......)

2 个答案:

答案 0 :(得分:2)

首先,我们不要假设你在哪里远程(这个词是什么!)。

以下是我认为您已经完成的一些步骤

在(a)终端:

cd "/path/name/to/repo/folder" # this folder should/ can contain all of your files and folders for the project
git init # initialize the repository
git add * # add everything (the * is like in a reg ex)
git commit -m "have to make a first commit"

也许您正在寻找

git remote add origin https://example.com/userName/repoName
git push -u origin master

所以userName就像" bordeo"。 " site.com"可能是" github.com"。

例如,转到GitHub.com并创建该回购。然后复制链接并将其插入git remote add origin

之后

如果你偶然想要克隆一个远程仓库(即它已经存在于GitHub上,你想要它在你的本地机器上,并让你的本地机器设置为推送到GitHub),然后你可以做到以下几点:

将您的目录(使用cd)更改为包含存储库文件夹的文件夹(如果您需要foo/MyRepocd到{{1 ,foo文件夹将在下一个命令中创建),然后执行MyRepo

答案 1 :(得分:0)

假设您(a)意味着GitHub(b)只是在您要上传的目录中运行git init

前往https://github.com/new建立上游回购。然后GitHub为你提供方向,就像这些名为" blah:"

git remote add origin https://github.com/mjb/blah.git
git push -u origin master