1

I am in need of some assistance.

Here's the scenario:-

I checked out a repo from GitHub using NetBeans and it was opened as a Java project. I added some functions to the project. Now when the maintainer of the GitHub repo pushes an update, how would I get my copy to have all of the changes that the latest one has without re-checking out the HEAD revision and copy pasting the functions manually?

Thanks in advance!

Sincerely.

yshavit
  • 42,327
  • 7
  • 87
  • 124

3 Answers3

1

With Netbeans, what you would do is:

enter image description here

https://blogs.oracle.com/geertjan/resource/git-rebase-in-74-dialog.png

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • When I check the repository out, does it have to be `origin:`? –  May 27 '14 at 08:56
  • @synquall no, it is just what the screenshot was displaying. In your case, you should fetch from the right remote. It usually is 'origin', but its associated url depends entirely on your own project url. – VonC May 27 '14 at 09:10
  • Alright, will try it in a bit and I will get back to you. –  May 27 '14 at 09:35
  • Finally figured out how to use it. Thanks! –  May 29 '14 at 02:22
0

When you are ready to PUSH from NetBeans, it will let you know you are behind the HEAD, forcing you to PULL first.

Preemptively, You'll want to PULL or FETCH to get the latest changes. The differences between the two can be found here What is the difference between 'git pull' and 'git fetch'?

Community
  • 1
  • 1
RS3
  • 194
  • 1
  • 3
  • 15
0

As stated in the comment, issuing the pull command will get the remote copy and merge it into the changes you made on the local repository:

git pull <remote> "Fetch the specified remote’s copy of the current branch and immediately merge it into the local copy. This is the same as git fetch followed by git merge origin/."

Another option is:

git pull --rebase <remote>

which will use rebase rather than merge to integrate the remote branch. See this tutorial, for example.

James King
  • 6,229
  • 3
  • 25
  • 40