It can be difficult to post your Django project to Github when you create your project first and then try to push it to Github. Typically there are errors saying that the master and the repository are incompatible and to try to pull from Github before doing a push. Also, the old trick of just dragging the outer project folder into the add files section of the Github website doesn't seem to be working.
You can manage the whole thing in Visual Studio Code. The solution is to create the Github repository first, Use VS Code to clone it to your machine, copy the files from the project into the clone directory and then push them up to Github.
On Windows you may have to download Git first. You can do this at https://git-scm.com/downloads
After downloading it, your will need to configure it. Instructions for that are at https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup. Your need to run the git bash shell as administrator and add a username and email. This is necessary for the commit.

Step by Step
Step 1 Create Github Directory
Go to your Github directory make sure you are logged in.
Create a new Repository. I will create a PythonClub repository, since that is the assignment project.
Click the plus sign in the upper right corner of the web site and select NEW REPOSITORY

This opens the new repository dialog. Key in the name. I usually like to initialize the repository with a readme. Click Create Repository.

Clone Repository
Now in Visual Studio Code Click the settings icon in the lower left corner of VSCode or key in CTRL SHIFT P to get the command Palette. Type Git and choose Git Clone.
Type in the Repository URL
Press Enter
Choose the folder where you want to create the repository. It should be near the Python virtual environment. In this case I am using the djangoprojects folder on my machine. Click Select Repository Location button.
Visual Studio code will ask you if you want to open the new repository. Just say yes.
The initial repository will have nothing but the readme file.
Now using the Windows File Explorer, drag the project and app folders into the new repository folder. Make sure you include manage.py

Now you can see the files in Visual Studio Code

Notice the U beside each file. That means the files are unmanaged. We need to change that.
If you click the git icon--the one with the numbers on it--it will open a git command line and tools. Type Git add -A in the command area. Mouse over Changes and Hit the + to stage all changes.

Click the three dots by the Source Control: git at the top of the git panel and select Commit all. This will commit all the new files in your local repository. Next, click those three dots and choose push to. It will show you the source you cloned from. Select that. It will also ask for your Github username and password. Provide those and enter.
Now your github will be updated.

Now you can do all your git updates through VSCode.
This is an amazing blog, thank you so much for sharing such valuable information with us.
ReplyDeleteDjango Online Courses
Django Training in Hyderabad
Python Django Online Training
Python Django Training in Hyderabad