0

Here's my situation....

I have created a repository on GitHub of a project. I worked on the project on a different computer then that which I have created the repository on. I now need to update the GitHub with the changes. I'm working from Android Studio. It seems the only option I have is to either create a new repository. I want to know how to update my old one without having to clone it and modify it then upload changes.

6
  • "I want to know how to update my old one without having to clone it and modify it then upload changes." How did you start working on it on your second machine if not by cloning it?
    – Chris
    Commented Aug 25, 2018 at 18:04
  • A back up zip file. Commented Aug 25, 2018 at 18:05
  • Did you try to copy and paste your .git folder and .gitignore file from your Github repository to your newly created folder? Commented Aug 25, 2018 at 18:09
  • no.... do u advise this ? Commented Aug 25, 2018 at 18:09
  • Possible duplicate of How do I clone into a non-empty directory?
    – phd
    Commented Aug 26, 2018 at 21:52

2 Answers 2

1

When you worked on the separate computer did you clone the repo? If so you can just push your changes. If not, you'll need to setup a remote

first init a git repo if your work is not in a git repo git init

then add a remote git remote add origin https://github.com/user/repo.git

use git remote -v to verify

set upstream git remote add upstream

then pull, commit, push your changes now that your remote is setup

https://help.github.com/articles/adding-a-remote/

0

make a new git repo on your new PC using git init, this will add your project to a new repo on your machine. add all your source to this new repo using a

git commit -am "whatever description of changes made"

Now checkout a new branch, call it what you like, but something like

`git checkout -b new_work`

should do the trick.

Now switch back to your master branch using git checkout master and connect your repo to your remote git repository on github

git remote add origin https://github.com/user/repo.git

You can set the upstream then using

`git remote add upstream`

Next you pull the remote code into your master branch using

git pull https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git BRANCH_NAME

Now you can merge all your new changes back into the master branch as you would in your normal workflow using

`git merge new_work`

or whatever you called your new branch.

Then push the master back to github using

 `git push`

This approach has the advantage of being able to track all your changes properly and reverse them if needs be or amend update as needed whilst keeping the original code in tact and is the normal workflow for git. Of course in the future you would pull the repo from git before making any changes and you wouldn't have this problem. Hope that helps

Not the answer you're looking for? Browse other questions tagged or ask your own question.