1

I have an existing repository in Github. But how do I commit changes and push the files to a particular directory in that repository?

Note - I've done all the steps from git remote add origin to 'git commit' to 'git push` but, how do I select that particular directory I want to push changes into the repository from the terminal.

PS - I want to push changes from my local [which is not in my project directory] to a particular existing Directory of the Repository.

Rahul Bordoloi
  • 145
  • 3
  • 9
  • The question seems unclear. You would have a local copy of the repository containing all the directories in the remote repository. Just place your files there. – GoodDeeds Jun 29 '20 at 03:27
  • @GoodDeeds Suppose I've created some files in a `temp` local directory [which is not in my project directory for some reasons] and I wanna push the files inside the `temp` folder to a pre-existing directory of my repository using `git remote add`. I'm facing my problems there. Hope you get my point. – Rahul Bordoloi Jun 29 '20 at 03:57
  • 1
    [This](https://stackoverflow.com/q/50451684/5987698) may help. – GoodDeeds Jun 29 '20 at 04:01

1 Answers1

1

Suppose I've created some files in a temp local directory [which is not in my project directory for some reasons] and I wanna push the files inside the temp folder to a pre-existing directory of my repository using git remote add. I

First, git remote add is just to declare a remote URL: it does not add or push any file.

Second, simply copy those file in the local repository, with the right folder.
Then:

git add theRightFolder
git commit -m "Add theRightFolder content"
git push -u origin master

If that folder includes other files you do not want to push, you will need to git add only the files you have copied

git add theRightFolder/file1
...
git add theRightFolder/filen

git commit -m "Add some files in theRightFolder"
git push -u origin master
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250