Search Unity

How can I update my forked git repository master from the main master?

Discussion in 'Open Projects' started by midlifemachine, Oct 4, 2020.

  1. midlifemachine

    midlifemachine

    Joined:
    Sep 21, 2020
    Posts:
    4
    Hi all,

    I am fairly new to programming and using Git Hub. Git says that my branch is 13 commits behind UnityTechnologies:master.

    Simple question. How can I update my repository so that I can work with the latest code?

    Thanks,
    Christoph
     
    Pritte likes this.
  2. midlifemachine

    midlifemachine

    Joined:
    Sep 21, 2020
    Posts:
    4
    I think I found a way to update the repository. Did a pull request on my own forked repository and approved it so that the Unity Master gets merged with my forked master.

    Looks like that worked. Please let me know, if this was the wrong solution.

    Quick question. My repository now says: 'This branch is 1 commit ahead of UnityTechnologies:master.'

    Will that be a problem?
     
  3. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    Yes, you could have also just merged (you don't need to open a request on your own repo).
    Merging means that you are taking all the 13 changes that are on master, and merging them into your work. Now that they are merged, you are up to date with master.

    If you are ahead it means that you produced new changes, and so now technically Unity's master is behind you. When you open a pull request (PR) you are asking Unity to pull (and merge) your work into their master, bringing Unity's master to your level... so they are up to date with you.

    Clear?
     
    Pritte likes this.
  4. Pritte

    Pritte

    Joined:
    May 28, 2017
    Posts:
    1
    I was having the same difficulty, since I've never had to use forks, pull requests, etc.
    I found out this link

    It speaks of what Ciro was saying about merging, if you're using Github Desktop, this might make your job easier, good luck!
     
  5. midlifemachine

    midlifemachine

    Joined:
    Sep 21, 2020
    Posts:
    4
    Thanks for your reply.

    It makes sense, but I wasn't clear how to merge without doing a pull request. I couldn't find a merge option or button on github.com when in my repository.

    Looks like overnight there were 14 new commits on the master:

    'This branch is 1 commit ahead, 14 commits behind UnityTechnologies:master.'

    I am unsure how I can merge those 14 commits from UnityTechnologies:master now into my forked repository.

    Pritte, I'll check out the link that you shared to see if that helps.

    Thanks a lot!
     
    Pritte likes this.
  6. midlifemachine

    midlifemachine

    Joined:
    Sep 21, 2020
    Posts:
    4
    yes, I managed to merge the updates into my local repository using GitHub Desktop.

    Thanks all for the help!
     
    Pritte likes this.
  7. hemanthvanam

    hemanthvanam

    Joined:
    Mar 3, 2019
    Posts:
    11
    You can use this extension from the github marketplace for keeping your forked repository upto date. Github will automatically merge the new commits from unity's repo to your repo as soon as the new merges are made to unity's repo.
    But you will have to work on a new branch not on the master branch or your repository which is recommended whether you use this extension or not.
     
    GhAyoub likes this.