kushal chawda
kushal chawda

Reputation: 43

Push files from local folder to folder in a github repository

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?

Upvotes: 4

Views: 23800

Answers (3)

Sanju Chandra
Sanju Chandra

Reputation: 101

This is working solution :

  1. git clone "your remote repo" i.e git clone https://github.com/username/file.git
  2. cd into file and remove everything which you already have in local(to push into remote) file except .git file using finder/file manager
  3. cd local file
  4. cut/copy everything from local except .git into file(cloned from remote)
  5. git add .
  6. git commit -m "msg"
  7. git push

This will solve the problem.

Upvotes: 1

joran
joran

Reputation: 2893

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

Upvotes: 2

veben
veben

Reputation: 22362

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

Upvotes: 7

Related Questions