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.

David Kachlon
  • 201
  • 3
  • 14

2 Answers2

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/

Zachary Sweigart
  • 1,051
  • 9
  • 23
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

jamesc
  • 12,423
  • 15
  • 74
  • 113