Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push files from local folder to folder in a github repository

Tags:

git

github

I have one repository on github. In this repository I have created one folder. Now I want to push files using git command from local folder to folder which I have created under github repository.

Can anybody help me on this?

like image 831
kushal chawda Avatar asked Sep 05 '25 03:09

kushal chawda


2 Answers

You have to:

  1. Init a local repository
  2. Define the origin to the remote repository
  3. Add the file to the index
  4. Commit the files
  5. Push the files from the local repository to the remote

It leads to something like that:

cd yourLocalFolder
git init
git remote add origin https://github.com/<yourLogin>/<yourRepository>.git
git add .
git commit -m "Initial commit"
git push -u origin master
like image 133
veben Avatar answered Sep 08 '25 02:09

veben


If you are new to git I recommend reading a tutorial (you can find a short intro at http://rogerdudler.github.io/git-guide/).

Normally, to work with an existing remote git repository you need to have a local copy if it. You do some changes locally and push those changes to the remote repository.

git clone https://github.com/username/myproject.git
cd myproject
<make some changes locally>
git add .
git commit -m "Fixing something"
git push origin master

In your case you may need to copy the files (and create the folder in the local repository) that you want to push to github into the local repository (before git add .).

like image 29
joran Avatar answered Sep 08 '25 02:09

joran