Git questions

Hi,
If I have the project forked on my local and I want to update it with the main branch, how can I do it? Do I have to delete my forked first and fork again? (I hope there is a better solution)
Thanks

You just need to click Pull or Fetch Origin button in GitHub desktop

No, this will pull from your fork’s remote on GitHub, not from the main repo.

Have you setted it up correctly? see the contribution guide if you haven’t yet.

No, you don’t need to delete the fork.
This guide goes over it quite well: The Git Fork-Branch-Pull Workflow | Tomas Beuzen
But I can also explain briefly. I will add numbers in my explanation referring to the paragraphs in that guide.

The way it works is this:
Let’s say that our repo and branch are UnityTechnologies:master. We call this the “origin”.

You fork the repo (i.e. just create a copy on Github). Then you open whatever application you use (Github Desktop, SourceTree, Fork, Gitkraken, or just the command line) and you pull your fork’s master, say fran_m:master and you start working there. At this point you could also branch locally, say create a fran_m:bugfix branch.

If for any reason, the origin master updates (for instance, we merge another PR into it) it would be great if you take those changes before opening a PR. To do that, you need to add the original repo (not your forked one) as a remote in your desktop application (3).

Now you can pull from the original UnityTechnologies:master, and merge the new stuff into your fran_m:master or fran_m:bugfix, depending on which one you are using (8).

Once ready, you open a PR on Github, knowing that the changes you are sending are up to date with the latest on our master, which means it’s going to be easier for me to merge them :slight_smile:

1 Like

I do I get assigned to some task in this project?

Sorry, i didn’t understood what you said here

I said that I have did some changes and updates to the project, but how do I get approved my work by officials
See here, I have described

https://discussions.unity.com/t/813095

Based on rules. At first, You must made request to make changes, then receive rights to made changes of some part of project, made the changes and only after that make new pull request.
I feel that you skipped many demanded steps
More detail it described in

.

I have opened a pull request from my repo/master to unity repo/main. Now I don’t know if the will accept it or not. From then, there are many commits to the unity’s repo. On my repo, it show that

This branch is 1 commit ahead and 13 commits behind unitytecnology’s/main

So what should I do now.
To update my local and github repo I should

git pull upstream main (I call upstream unity’s one)
git push origin master (origin is mine)

But then what about my contribution that is on my local computer and on my github but not in unity’s repo, will it be merged or deleted? And if maintainers will not accept the pull request, I will have my contribution (if it’s merged) and the main one will not.

If I right understand the your PR is Created Beach Skybox #128. (You can see by link current status of our PR)
It’s in queue of all requests for changing " UnityTechnologies:main" (It’s the main branch of repo for this project)
As how i see the @cirocontinisio saw your PR (changed label PR). Your PR passed check & ready to merge. I think in nearest time it will be merged.

It’s ok, it means that from last time of sync your copy repo, in repo was merged 13 new commits and you have 1 local commit which yet merged to repo.
If you want you can pull new commits (13) to your local copy of repo (branch).
But it is non mandatory (if you do not plan to change the files what was changed)

It’s based on, how you made fork and local branch, which tools you used. For absolutely correct answer at first demanding to see your config (output from the commands below)
For check can run these command - it doesn’t change nothing, but can show your config clear

git remote -v
git remote -v show upstream
get fetch -all
git branch -vv
```.
[quote="Harsh-NJ, post:10, topic: 812061, username:Harsh-NJ"]
But then what about my contribution that is on my local computer and on my github but not in unity's repo, will it be merged or deleted? .
[/quote]
Your contribution in the pull of request. Also i think :) if you didn't use special git commands, It's in your local branch on computer and also may be at your local copy repo on Github.
Many variants based on your config, but either will be merged, either will left at separed branch (with updated based branch) and you can merge it together later. (By Git commands you can did what you want, by GitHub Desktop variants are more predetermined, but it enough for most standard cases)
[quote="Harsh-NJ, post:10, topic: 812061, username:Harsh-NJ"]
And if maintainers will not accept the pull request,, I will have my contribution (if it's merged) and the main one will not.
[/quote]
I didn't understand this, and this in your case is not very realistic

OFFTOP
:eyes:
I finish my first read of Git documentation and :smile:ready to change status on social networks on
**Do not rebase commits that exist outside your repository and that people may have based work on.**
[quote=Git documentation]
...If you follow that guideline, you’ll be fine. If you don’t, people will hate you, and you’ll be scorned by friends and family:(.
[/quote]

That’s correct.

1: you pull the newest changes locally to your computer
2: you push them to your remote fork

By doing so, your fork is now aligned with Unity’s repo, which should automatically update the PR. On top of that, your contribution will still be there (not lost).

Outputs of commands
(I followed a tutorial so I have added upstream remote)

$ git remote -v
origin GitHub - HarshNarayanJha/open-project-1: Unity Open Project #1: Action-adventure (fetch)
origin GitHub - HarshNarayanJha/open-project-1: Unity Open Project #1: Action-adventure (push)
upstream GitHub - UnityTechnologies/open-project-1: Unity Open Project #1: Chop Chop (fetch)
upstream GitHub - UnityTechnologies/open-project-1: Unity Open Project #1: Chop Chop (push)

$ git branch -vv

  • master 8cc83a0 [origin/master] Created Beach Sky box

$ git remote -v show upstream

Yes, your made standard configuration.
If I right understood, You didn’t make separate branch for your changes (I doesn’t see it in output “git branch -vv” or you remove it). In this case @cirocontinisio absolute right “git pull” made merge “your PR” with newest Repo changes (it will be did on your local comp), “git push” sync your local files with your copy Repo (your remote fork).
P.S>
If you have separated branch for make changes, it was a little different (you can select make the same merge of your changes with update or make rebase for your branch).

OK, now for next pull request I shall make a new branch with the name of that branch specific feature or bugfix. Then use git switch to switch the branch and then git add, git commit and then git push, right? After the pull request is merged, I may delete that new branch after pulling and pushing to my master branch.
And until the pull request is merged, I should left the another branch as it is and update the master branch only?

Create of separated (new) branch it’s not mandatory for creation new features or bufixes, but recommended.

  • git switch to switch the branch
  • made changes
  • after git add, git commit to made new commit with changes on local Repo on PC
  • after git push to move commit to your local remote Repo (but it’s not mandatory)
  • after made Pull Request to 'Upstream" from local Repo on PC or from your local remote Repo

Your master (main) and “new branch” fully separated therefore you can update main in any time regardless from state of your work in “new branch”.

To simplify work for Integration managers of " UnityTechnologies:main" you can before made Pull Request to 'Upstream":

  • “pull the newest changes locally to your computer” to local branch main
  • rebase your “new branch” to update “local branch main”
  • only after that make the Pull Request to 'Upstream"

Your “new branch” will be fully not necessary after when your PR was merged in Upstream/main and you pull the new version of it.

1 Like

I didn’t use GitHub often before this project (especial for disturbed development), therefore many simple Git tasks & questions wasn’t clear to me. And I spent some time to find information & did some tests. I decided “shortly describe” the main tasks & variants of use Git concern to this project.
I did the most tasks by GitHub Desktop.
The standard command line Git interface only used for recieve some information which absent in “Desktop interface”.
I made video and put on Youtube (see description for timecode!!!), i think it may be helpful for beginners (“Git&Unity project”).
In any case, I recommend you begin watch from Dapper Dino video.

In process of rebasing the local branch to new base, I met with a issue - problem of conflict of changes in Scene.unity files from combining branches (not good results of using git rebase/merge and UnityYAMLMerge:): I discussed this issue on Unity forum and get information about way to workaround this issue link to certain post (not to double information), where I detail explain the workaround.

Ah yes, that’s also my workaround when there’s a conflict with scenes: rename your local one, pull in the new one, and then do a manual copy-paste of the object you know you want to preserve.
It’s tedious, but it’s the only way.

It’s very strange that “Unity Inc” didn’t make the tools which help to right menage the process of merging Unity scenes?