0

I am working with a small team for the Unity game project and for the management of the project, we were using Github with its Desktop software.

We all members working on own branch and then merging work to Main branch and take other members content from the Main branch.

Now I got stuck in problem because I am new user for Github so I couldn't able to understand push and pull for multiple branches.

This is my current Github repository status: enter image description here

I have worked within the project so I have new data compare to my last commit but other team members also worked so they committed the data as you see in the above image.

So before I made my commit, I have to take data from them which exist in the Main branch. I have done these steps:

  1. Pushed changes to my branch
  2. Take update from the Main branch to my branch
  3. Open the Unity project to solve any errors

Surprisingly as I opened the project, I noticed that I have lost project latest work that I did after my last successful commit. I don't know other members' data exist within my system or not but definitely, I lost my progress.

So how to fix the GitHub workflow? I don't want to disturb other members. I have already taken a backup of my project within my HDD before doing Github-related stuff.

Commit Options:

enter image description here

My Branch Status: enter image description here

Siddharth
  • 4,142
  • 9
  • 44
  • 90

1 Answers1

0

From your picture I can see you are still on current branch: main .. no wonder your files do not exist there as you added them on your own branch ;)

You want to

  1. If you haven't done yet fetch the main to see if there are any new commits online (most GUIs do this automatically in certain intervals). Then pull the main in order to actually download these new commits

  2. checkout back into your own branch (via the Current Branch Dropdown)

  3. merge the main into your own branch

Never worked with Github Desktop but this is generally Git and works the same in any GUI tool.

I recommend you watch some basic tutorials about the git commands and workflows in general.

This one I tried to sum up here is also described in detail in GitHub Desktop -> Syncing Your Branch

derHugo
  • 83,094
  • 9
  • 75
  • 115
  • There is no checkout option exist within the whole software. – Siddharth Jul 15 '21 at 19:43
  • I have added 2 images within the question: 1) commit available options 2) my working branch history so you can see what steps I did. Within my local HDD latest data does not exist that I worked with or any other members. Still I commit my branch data to main branch? – Siddharth Jul 15 '21 at 19:45
  • Checkout is basically switching branch from central dropdown. In this software (that i use), i would commit my branch, switch to main, fetch and pull main, switch back to my branch, update from main, fix any issues, push my branch. Then, when done with my work, switch to main and update main from my branch. Do it as often as possible to avoid large merges that are more likely to conflict. – Everts Jul 15 '21 at 20:15
  • @Siddharth well from the last image it looks like you merged from the main into your branch but never back into the main branch. Do the files exist if you are on `Current branch sid_work`? The `Github Desktop` seems to execute the `checkout` as soon as you change the `Current Branch` vis that Dropdown – derHugo Jul 15 '21 at 21:02
  • @derHugo current branch shows to be sid_branch and last commit is the merge from main (that would not show if he was in main). I think his problem is that he merged without committing. – fafase Jul 16 '21 at 06:04
  • @fafase well these images were added later .. my answer was based on the first one which says that current branch is `main` and there was no merge of `sid_work` back into `main` – derHugo Jul 16 '21 at 14:03