简体   繁体   English

如何将 python 文件添加到 github 中的新存储库

[英]How to add python files to a new repository in github

I am trying to learn and understand basics of github.我正在尝试学习和理解 github 的基础知识。 For the purpose, I created some files.为此,我创建了一些文件。

  1. try_catch_basics.py try_catch_basics.py
  2. reading_from_files.py and countries.txt reading_from_files.py 和 countries.txt
  3. writing_in_files.py and country.txt writing_in_files.py 和 country.txt

Now, I had created a repository earlier with name try-catch-basics, and included the first file in it.现在,我之前创建了一个名为 try-catch-basics 的存储库,并将第一个文件包含在其中。 I wanted to include my second and third files in the new repository that I created, but I am not able to do that.我想将我的第二个和第三个文件包含在我创建的新存储库中,但我无法做到这一点。 Here are the steps that I followed for the same -以下是我遵循的相同步骤 -

View -> Command Palette -> Git: Add Remote ->https://github.com/SteelTitan247/File-handling-in-python -> Gave a name -> and pressed enter.查看 -> 命令面板 -> Git:添加远程 -> https://github.com/SteelTitan247/File-handling-in-python -> 命名 -> 然后按回车键。

Then, I clicked source control and commited with a message.然后,我单击源代码管理并提交了一条消息。 Now, an option is showing me for sync changes.现在,一个选项正在向我显示同步更改。

在此处输入图像描述

When I am clicking on it, it is showing me this -当我点击它时,它向我展示了这个 -

在此处输入图像描述

which is the previously created repo for my file 1. How do I "shift" or change repo from this to my new one?这是我的文件 1 之前创建的回购协议。如何将回购协议“转移”或更改为我的新回购协议?

For reference, this is the older repo - https://github.com/SteelTitan247/try-catch-basics作为参考,这是较旧的回购 - https://github.com/SteelTitan247/try-catch-basics

And this is the one in which I want to push my new files - https://github.com/SteelTitan247/File-handling-in-python这是我要推送新文件的文件 - https://github.com/SteelTitan247/File-handling-in-python

Please correct my mistakes and guide me through it.请纠正我的错误并指导我完成它。

New repository you got page like this.新的存储库你得到这样的页面。

在此处输入图像描述

Click on upload existing files and drop your files in next window单击上传现有文件并将文件拖放到下一个窗口中

在此处输入图像描述

Enter your commit message and click on commit changes输入您的提交消息并单击提交更改

Now you have files in your repository!现在你的存储库中有文件了! now clone your repository from vs code and start working with git现在从 vs code 克隆你的存储库并开始使用 git

I usually use the GitHub application itself, in it, to upload my files to another repository, I would first have to sync the repository and then move or copy the files to the chosen folder.我通常使用 GitHub 应用程序本身,在其中将我的文件上传到另一个存储库,我首先必须同步存储库,然后将文件移动或复制到所选文件夹。 After that perform the commit and pull之后执行提交和拉取

  1. You can use source tree tool and clone git repo in your project and than you can add/[commit,push] your files您可以在您的项目中使用源代码树工具和克隆 git repo,然后您可以添加/[提交,推送] 您的文件

  2. You can drag and drop files manually for very first time in main branch and than clone your repository in new location and than ready to go!您可以第一次在主分支中手动拖放文件,然后在新位置克隆您的存储库,然后就可以开始了!

  3. In vs code first clone your repository and than push your files.在 vs 代码中,首先克隆您的存储库,然后推送您的文件。 Open your local project.打开您的本地项目。

    3.1 VSCode source control interface showing Open Folder and CLone Repository 3.1 显示打开文件夹和克隆存储库的 VSCode 源代码控制界面

    3.2 Add a README.md file (If you don't have anything else to add yet) 3.2 添加一个 README.md 文件(如果你还没有其他东西要添加的话)

    3.3 VSCode explorer interface showing README.md 3.3 VSCode 浏览器界面显示 README.md

    3.4 Click on Publish on Github 3.4 点击发布到Github

    3.5 VSCode source control interface showing Initialize Repository and Clone to GitHub 3.5 VSCode 源代码控制界面显示 Initialize Repository 和 Clone to GitHub

    3.6 Choose whether you want your repo to be private or public 3.6 选择你的回购是私人的还是公共的

    3.7 Interface showing choice between private and public repos 3.7 显示私人和公共回购之间选择的界面

    3.6 Choose the files you want to include in first commit. 3.6 选择要包含在第一次提交中的文件。

Note: If you don't select a file or folder it will added to.gitignore file注意:如果您不选择文件或文件夹,它将添加到 .gitignore 文件

Showing interface where you choose which files to include in the repo显示您选择要包含在回购中的文件的界面

You are good to go.你已准备好出发。 it is published.它已发布。

PS If this was your first time a prompt will ask for for your Github Credentials. PS 如果这是您第一次使用,系统会提示您提供 Github 凭据。 Fill those in and you are good to go.填写这些内容,您就可以开始了。 It is published.它已发布。

For more Information: How to add a new project to Github using VS Code更多信息: 如何使用 VS Code 将新项目添加到 Github

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何添加github文件夹的路径cdqa pdf_converter? 或者从python中的github存储库中提取pdf - how to add a path of a github folder too cdqa pdf_converter? Or extract pdf from a github repository in python 如何读取Github存储库中的所有文本文件? - How to read all text files in Github repository? 如何将 dataframe 作为 csv 保存到 github 存储库 Z23EEEB4347BDD26BFC6B7EE9A3B75 - How to save a dataframe as csv to github repository python Python 获取公共 GitHub 存储库中的 csv 文件列表 - Python get list of csv files in public GitHub repository 在新分支上为GitHub上的存储库做贡献 - Contributing to a repository on GitHub on a new branch GitHub,创建新存储库(Github API 令牌) - GitHub, creating new repository (Github API token) 如何在不登录的情况下从 Github 存储库下载文件? - How can I download files from a Github repository without logging in? 如何将新文件推送到 GitHub? - How do I push new files to GitHub? Github API 如何使用 python 语言获取具有特定扩展名(.c、.cpp、.py 等)的 git 存储库的所有文件的计数? - Github API How to get a count of all the files of a git repository with a particular extension (.c, .cpp, .py etc) using python language? 你怎么知道github存储库是用于python 2还是python 3 - how can you tell if github repository is for python 2 or python 3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM