Reputation: 497
If I have my python code located in a folder on my Desktop and need to upload it to GitHub, how do I do that? I just created an account on GitHub.
Upvotes: 1
Views: 12925
Reputation: 29
Initially when you create repositry do the following:
readme.md
file you'll see a button 'upload files'. You can either browse to upload or drag the entire folder from your system.Upvotes: 0
Reputation:
Make sure Git is installed in your machine or you can get it here.
Go to your GitHub account and beside your profile to the far top right, you'll see a + icon.
Click on it and select "New repository". Give it a name and a description if you like then "Create repository"
Go to your folder and open a terminal.
Type
git init
This will initialize git in that folder. Then you should add your GitHub repository you created early as a remote repository to enable push code to it and also pull from it. Do:
git remote add origin https://github.com/yourname/githubrepo.git
you can check if the repository you add is correctly placed as your remote repository
git remote -v
Then add your file(s) to the staging area
git add file.py
and commit your changes to create a history of commits and enable you to push
git commit -m "commit message"
then you can push your file(s) to your remote repository
git push origin master
Go and refresh your Github repository and you'll see your file(s) there.
Hope it helps.
Upvotes: 3
Reputation: 161
In a Linux bash terminal, you can use the following commands directly. In Windows, you can open the "git bash" terminal and run these same commands.
git init
This creates a new git repository in whatever folder you run the command from.
git add myCode.py
git commit -m "Some message describing what you did"
This ensures that your code is saved to a commit.
git remote add origin https://github.com/yourUsername/nameOfYourRepo.git
This makes a reference to your github repository called "origin"
git push origin master
This pushes all of your local commits to the master branch of your github repository. You can change "master" to other branch names to push to those as desired. You can also pull from your github repository using
git pull origin branchName
Note: You may have to input your github user/pass when doing this. You will also probably have to configure your name and email address on your local machine. If so, git will notify you of this and tell you in the terminal how to do it.
Upvotes: 0
Reputation: 129
First you need to install Git on your os.
and then follow the step by step from Github:
https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
Upvotes: 3
Reputation: 91
You'll have to make a local git repository and then set a github repository as the remote repository.
https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
Upvotes: 2