-1

I work on a Django project with git and I am lost.

In local I have 3 branch:

  • master
  • feature/4
  • feature/6 (derived from feature/4)

so my most advance branch is feature/6

I would like to merge with master but I have conflicts I do not manage to resolve

In my remote repository (Gitlab), I push my feature/6 branch and make a merge request.

But due ton conflict, I can't merge and Gitlab do not let me resolve conflict (no button available)

what should I do?

SLATER
  • 613
  • 9
  • 31
  • 2
    do pull from the remote branch first and resolve conflicts locally. then do push. – Serge Nov 29 '19 at 13:58
  • 1
    [Configuring `mergetool`](https://gist.github.com/karenyyng/f19ff75c60f18b4b8149) correctly might help to get you going – Zeitounator Nov 29 '19 at 14:01
  • `Gitlab do not let me resolve conflict (no button available)` - resolve conflict manually checking which files has got conflict as shown, then push to remote. – user404 Nov 29 '19 at 14:01
  • gitlab give me a message: You can merge this merge request manually using the command line but I fear doing wrong as I may have do many things wrong until now... – SLATER Nov 29 '19 at 14:05
  • Step 1. Fetch and check out the branch for this merge request git fetch origin git checkout -b "feature/6" "origin/feature/6" – SLATER Nov 29 '19 at 14:06
  • @SLATER: do it wrong and learn from your mistakes. 100% of successful people have failed at least once. – Zeitounator Nov 29 '19 at 14:12
  • I highly recommend to use a 3-way merge application like KDiff3 for example to solve conflicts. It usually manages to solve majority of conflicts itself, you just have to solve the rest manually. It's really huge time (and headache) saver. – David Ferenczy Rogožan Nov 29 '19 at 14:12
  • so to do step by step : first I do git fetch origin – SLATER Nov 29 '19 at 14:34
  • then try to do git checkout -b "feature/6" "origin/feature/6" and already have an error – SLATER Nov 29 '19 at 14:34
  • fatal: A branch named 'feature/6' already exists. – SLATER Nov 29 '19 at 14:35
  • the problem is that I do but did not understand nothing what I do ! – SLATER Nov 29 '19 at 14:35

2 Answers2

0

You need to

  1. git checkout master and pull all the newest changes.
  2. git checkout feature/6 and merge it with master localy. If you have merge conflicts here, I suggest to install and learn basics about kdiff3. It is a awesome superior tool to help you with merge conflicts.
  3. After all local conflicts on feature/6 solved, you can switch to master and merge feature/6 with it, push to master now.

This is only one way how you can going. Finaly I suggest to learn some basic git workflow and commands. This will save you hours of time in future.

Tristate
  • 1,498
  • 2
  • 18
  • 38
  • noway: if I need to learn about another tool whereas I did not really understand Git I will never end; I have done a git diff --color-words master..feature/6 to see conflicts and there so many... I am using VS Code: is there a way to manage merge conflict with it like would do Kdiff3? – SLATER Nov 29 '19 at 15:30
  • `git diff` will show you all *changes* not all *conflicts*. – Brondahl Jan 21 '21 at 13:40
0

well I'va tried to understand better what I have done and realized I have done whatever !

git log --oneline --decorate --graph --all

enter image description here

My last "clean" commit on my feature/6 branch was 0542d3f (yellow arrow) and I should have merge with master at this point. When I look on Gitlab this the commit I have push.

But I have done many actions after... I want to merge at this point. So I think I should go back to this commit (git checkout 0542d3f) to merge with my master branch state at this point that seems to be commit aea55d29

but I have an error with git checkout 0542d3f:

Your local changes to the following files would be overwritten by checkout: db.sqlite3

Please commit your changes or stash them before you switch branches. Aborting

I have started to look for Kdiff3 but don see how to compare 2 differents locals branch. I see it can compare two files...

thanks in advance for your help

enter image description here

SLATER
  • 613
  • 9
  • 31