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++?
Your Repo A is on github.com 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 https://github.com/mewben39/RepoA.git
this will clone your remote repo locally to (this will also contain .git folder but its hidden)
RepoA contains code from github.com 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' thengit push`.
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 github.com/mewiben39/repoA.git
then git push with force flag. Using force flag is not recommended.