Peck3277
Peck3277

Reputation: 1423

Add a cloned github project to eclipse, setup push/pull to github

I'm a small bit confused with git/github. I've git setup on my desktop and I'm able to push changes to github fine.

I want to be able to also work on my project from my laptop. I've cloned my project using

git clone url project

So I now have it on my PC. I want to add this project to eclipse and I also want to be able to push and pull changes to github but I'm not sure how to do this.

Do I need to init a new .git file and re add all the files?

Upvotes: 0

Views: 116

Answers (2)

Code-Apprentice
Code-Apprentice

Reputation: 83527

If the project is already configured to be used in Eclipse, you can just open it directly. There is nothing more you need to do.

Once you already have a repo, there is no reason to go through all the work again. This is one of the points of using version control. You only need to clone the repo to another machine to continue working on it. To get the project on your laptop, do the same thing as you did on the PC:

$ git clone <URL to GitHub repo> <project directory>

When you make changes on the PC, commit them:

$ cd <project directory>
$ git add .
$ git commit

And push them to the GitHub repo:

$ git push origin master

Now you can update the code on your laptop:

$ git pull origin master

You can also do these in reverse: make changes on the laptop, push them to GitHub and pull them to your PC. The commands are the exact same.

Upvotes: 0

Bishakh Ghosh
Bishakh Ghosh

Reputation: 1258

No need to init a new .git file.

Assuming you already have your repository in github your steps should be:

  1. git clone url project - here url should be your github repository url
  2. cd project
  3. Now work on eclipse
  4. Now back to that shell: git status should give you the changes you have made.
  5. git add . to track all changes.
  6. git commit
  7. git push <remote-name> <branch-name> which in most cases is git push origin master
  8. Now in your other computer (laptop) you can do git pull origin master to pull the latest changes.

Upvotes: 1

Related Questions