简体   繁体   中英

How to add python files to a new repository in github

I am trying to learn and understand basics of github. For the purpose, I created some files.

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

Now, I had created a repository earlier with name try-catch-basics, and included the first file in it. 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.

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?

For reference, this is the older repo - 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

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

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. 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

  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. Open your local project.

    3.1 VSCode source control interface showing Open Folder and CLone Repository

    3.2 Add a README.md file (If you don't have anything else to add yet)

    3.3 VSCode explorer interface showing README.md

    3.4 Click on Publish on Github

    3.5 VSCode source control interface showing Initialize Repository and Clone to GitHub

    3.6 Choose whether you want your repo to be private or public

    3.7 Interface showing choice between private and public repos

    3.6 Choose the files you want to include in first commit.

Note: If you don't select a file or folder it will added to.gitignore file

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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM