Search code examples
gitrepository

Re-uploading a Git repository to a new remote


I have a local repository that I have uploaded to a remote repository.

All files were uploaded successfully, including the full history of commits. I then decided to delete that remote repository as I wanted to upload the code to a new remote repository.

I used git remote remove origin to disassociate my local repository from the first remote repository.

After I used git remote add origin <new repo url> and then git add -A and then the usual commit and push, I find that it only uploads recently modified files to the new repository, and not the full set that happened with the first remote repository upload.

My question is how do I reset what git considers has been already uploaded, so that this second remote repository can contain everything from my local repository, as it did with the first remote upload? I am looking for a solution that does not require me to manually amend each of the files that are shown up by typing git ls-files -v

I have scoured Stack Overflow and tried all of the following, but each with no success:

git add . -f (but this includes all files, including those stipulated to not be included according to .gitignore)

git update-index --no-assume-unchanged *.*

git push origin refs/remotes/origin/*:refs/heads/*

git update-index --really-refresh (but this has been reported on other sites to now not work)

Thank you for any pointers you might offer.


Solution

  • Ok, an update: I found that renaming the 'origin' to something else did not have the required effect. However git push -u origin --all seemed to do what I needed it to.