将本地文件系统中的项目推送到Github

我对将本地创建的文件夹(项目)推送到Github有点好奇。可能吗? 请让我解释一下我已经做了什么。 我正在Windows 8.1 64位上使用Windows版Git。

  1. 使用init命令在Git本地根目录(即项目)中创建一个新项目。请参阅下面的bash命令和消息。

$ git init fresh-project 在D:/MyDev/projects/fresh-project/.git /

中初始化空的Git存储库

2。

$ ls 新鲜项目/

  1. **$ cd fresh-project**

  2. **ls**

  3. **$ git status**
    

    在分支母版上

    尚无提交

    无需提交(创建/复制文件并使用“ git add”进行跟踪)

  4. **Used $ code hipster.txt**
    

    要通过打开VSCode并添加一些文本来创建文件。

  5. **$ git status**
    

    在分支母版上

    尚无提交

    未跟踪的文件: (使用“ git add ...”将要提交的内容包括在内) 时髦.txt

    没有添加任何内容来提交但存在未跟踪的文件(使用“ git add”进行跟踪)

  6. **$ git add hipster.txt**

  7. **$ git status**
    

    在分支母版上

    尚无提交

    要提交的更改: (使用“ git rm --cached ...”取消登台) 新文件:时髦.txt

  8. **$ git commit**
    

    提示:等待您的编辑器关闭文件... [main 2020-04-12T09:45:20.658Z] update#setState空闲 [main 2020-04-12T09:45:50.660Z] update#setState检查更新 [main 2020-04-12T09:45:50.870Z] update#setState空闲 [master(root-commit)b427f7c]使用时髦的ipsum添加新文件VSCode在2020年4月12日15:20完成 更改1个文件,插入1个(+) 创建模式100644时髦.txt

11。

$ git状态 在分支机构主管 没什么要提交的,正在工作的树很干净

After the 11th step I want to push the whole local repository to Github.com. I haven't created a 
repository in Github with the name of 'fresh-project'.

What else do I have to do to make this to happen?

感谢和问候, 吉兰萨卡

SKYyang0782 回答:将本地文件系统中的项目推送到Github

您应该已经在github上搜索了此内容。 要做的很简单,首先添加文件并提交,然后添加远程仓库URL并推送到github

$ git remote add origin https://github.com/user/yourremoterepo.git

如果要使用命令行创建存储库,则需要为此使用Github api 您需要访问令牌并卷曲才能进行POST回购

curl -H "Authorization: token ACCESS_TOKEN" --data '{"name":"Reponame"}' https://api.github.com/user/repos
,

如前所述,当您在Github上创建新存储库时,它将显示有关如何从命令行推送现有本地项目/存储库的步骤:

git remote add origin https://github.com/username/yourremoterepo.git
git push -u origin master

此外,您还可以如下使用-v来展示git存储的URL,这些URL用于读取/写入该远程仓库:

git remote -v
origin  https://github.com/username/yourremoterepo (fetch)
origin  https://github.com/username/yourremoterepo (push)

如果这没有指向您所需的项目(新鲜项目),则很有可能从未在Github上创建过该项目。否则创建遥控器的步骤未正确执行。

假设您自己是git的初学者,我建议您开始阅读Pro-git书。可以找到here。 有关使用遥控器的参考,请参见section 2.5

本文链接:https://www.f2er.com/2459464.html

大家都在问