kazi Raushan
kazi Raushan

Reputation: 49

How to upload in an Existing Repository?

I have a repository. I pushed files from a folder. Now I don't want to create new Repository. But I want to push files from a new Folder. The folders are almost same. How can I do this with command?

Upvotes: 0

Views: 1569

Answers (2)

Kavitha Karunakaran
Kavitha Karunakaran

Reputation: 1400

Assuming that you already have the repository created, you can do the following.

cd newfolder
git clone <link-to-clone-from>

Then copy the files to new folder. Check git status -s to see a summary of changed files in new folder after you copy files. Using git diff or beyondcompare can show you the exact changes that you are about to commit next. If everything looks fine, continue with the next steps

git add -a 

git commit -m "your commit message"

git push origin master

Upvotes: 1

Anduin Xue
Anduin Xue

Reputation: 3727

Assuming you have two folders:

- Old repo folder
  - .git
  - My old folders
  - My old files.
- New repo folder
  - My new folders
  - My new files.

And you want to replace all stuff in the remote repo from the old repo folder with the new repo folder.


To do that:

  • First, delete all content except the folder: .git in the Old repo folder.
  • Then, copy everything except the folder: .git from the New repo folder to the Old repo folder
  • And run commands in the Old repo folder:
$ git status

To get if everything is fine. Git will detect that you have replaced a lot of files and deleted many of them. Check the output.

$ git add . && git commit -m "Replace with new content"
$ git push

And this will save your changes and send it to remote server.

Upvotes: 0

Related Questions