How to upload an updated local repo to GitHub if I previously uploaded a version already?

Believe it or not, I'm still new to GitHub. I'm using GitHub Desktop.

I previously uploaded my repo to Github, let's call it Repo A.

Now I have a version of the same code of Repo A in my localhost, let's call it Repo A++ because some code in this repo has been updated. The old .git folder is no longer available.

So, how can I add and push Repo A++ in localhost to Repo A?

My concern is when I fetch (or pull, I'm not sure) Repo A from GitHub, will it overwrite all my updated files in Repo A++?

1 answer

  • answered 2022-05-04 11:03 Chang Zhao

    Your Repo A is on Lets assume its this path: And lets assume your directory on localhost is


    switch to a directory some other location lets say (below is my assumed directory) cd /home/mewben39/dev/git_clones/ then git clone

    this will clone your remote repo locally to (this will also contain .git folder but its hidden)


    RepoA contains code from which you want to be merged with RepoA++

    Now run the below command

    cp -rv /home/mewiben39/dev/RepoA++/*  /home/mewben39/dev/git_clones/RepoA/

    the above cp command will copy data from RepoA++ to RepoA

    now you have overwritten code from RepoA++ to RepoA on local,

    then navigate to RepoA you cloned locally and git add . and finally commit the code git commit -m 'copied code from RepoA++ to RepoA' then git push`.

    Remember git add . is not recommended I did it as you copying code from updated RepoA++ which is you are moving entire code base.

    Also, I have used this method because you mentioned you have code in RepoA++ updated.

    Alliteratively you can also navigate to RepoA++ and set remote URL to git remote set main

    then git push with force flag. Using force flag is not recommended.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum