4

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?

3
  • can you show the git status in your local clone of the github repository ?
    – erik258
    Commented Dec 27, 2018 at 17:59
  • 2
    Github has the best documentation. look into services.github.com/on-demand/downloads/…
    – Hith
    Commented Dec 27, 2018 at 18:00
  • Hi, I am new to git. My requirement is that I have one folder in local drive. It contains some file. I want to push these files into folder which I have created in github remote repository Commented Dec 27, 2018 at 18:05

3 Answers 3

7

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
2
  • This commands will work well in case I want to move files to repository. But I want to move files to folder which I have created under repository on github Commented Dec 27, 2018 at 18:28
  • I tried something like below but not working git remote add origin github.com/<yourLogin>/<yourRepository>/<folder name>.git Commented Dec 27, 2018 at 18:29
2

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

1

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.