Alex Chudinov
Alex Chudinov

Reputation: 724

Upload local repository to github.com

I have a git repository which exists fully locally inside my PC. I want to create remote clone of it onto the github.com. How can it be done?

Upvotes: 36

Views: 29279

Answers (6)

arnauth akb
arnauth akb

Reputation: 41

my way to upload existing local repository

  1. Make new repo(give a name but don't click any combo box to initialize).
  2. Open git bash in the local repo.
  3. add : `

name "origin" and "main" up to you. make sure you are logged in on local git bash.

*if you found error "403", try generate github PAT and do this

git remote set-url origin https://yourusername:[email protected]/yourusername/reponame.git

Upvotes: 4

sachin_ur
sachin_ur

Reputation: 2661

It looks like a very basic question, still follow the below steps

Step 1: You need to create a github repository first

Step 2: Then copy the URL of the github repo

Step 4: Then add remote for the github repo (git remote add origin "copied repo URL")

Step 3: Then clone the repo (Readme files will cloned) (git clone "copied repo URL")

Step 5: Then add file (git add * or git add . or git add file name)

Step 6: git commit -m "your message"

Step 7: Then push it (git push origin "branch name")

Login to github and check your Repository

Upvotes: 24

zivie doma
zivie doma

Reputation: 21

The easiest way in my opinion is to simply download the GitHub desktop client, there is an option to add a repository by dragging and dropping files or just navigating to the folder and then uploading it to GitHub account.

Upvotes: 2

Prakhar de Anand
Prakhar de Anand

Reputation: 189

1. If you have Github CLI then you just have to run the command- gh repo create after initialising your local repo with git.

2. If you don't have the Github CLI installed you can get it from here .

Upvotes: 1

Prakhar de Anand
Prakhar de Anand

Reputation: 189

  1. You first need to create a GitHub repo "without a README.md" file.

  2. On the next page,GitHub itself displays you the commands you need to run to push/upload your local repo.

  3. Go to your local repo through the terminal, paste those commands and you'll be good to go.

Upvotes: 4

Suragch
Suragch

Reputation: 511566

Add a new repository in GitHub and then in the folder on your computer that you want to upload to GitHub run the following commands (changing my_username and my_project to your situation):

git init
git add .
git commit -m "initial commit"
git remote add origin https://github.com/my_username/my_project.git
git push --set-upstream origin master

Notes

If this is your very first time setting up git on your local machine, then you need to add your username and email:

git config --global user.name "Bob"
git config --global user.email [email protected]

In the future when you make changes you can simply do the following:

git add .
git commit -m "description of what I changed"
git push

I also use git status a lot to see what has changed or is ready to commit.

Upvotes: 14

Related Questions