Git rebase ignoring same changed lines -


i had weird issue git rebase i’m trying understand. developer , me working on same project, both pushing/pulling develop branch. working on same files expect conflicts arise when pushing/pulling git.

so is:

  1. my colleague commits , pushes changes first.
  2. i commit changes but, before pushing, pull repo new updates. pull finishes no conflicts. i’m bit surprised think it’s luck didn’t modify same exact lines.
  3. after push commit doing git rebase, no errors or whatsoever.

we’re happy operation until realise there lines commented in version not in colleague’s. version last 1 pushed, lines remain commented on repo.

why git didn’t complain same line being different in each version? know git notices comments , marks them changes. because rebased instead of doing merge-commit? can me understand happened? i'm afraid of kind of changes going unnoticed , leading errors later on project.

your git flow wrong, 2 things here:

1) never use git rebase (or other commands modify history) on public branches. ok create branch, work on it, rebase , push it, don't rebase when pushed , used other people.

2) you're coming svn , got used work on single branch. git has lightweight branches , better create new branch every change:

  • never commit directly master branch, integration branch puts finished features together
  • create new branch each new feature , development there
  • once feature done, review change: if good, merge master
    • if there conflicts revert merge (or if use github, not allow merge it)
    • merge master branch
    • resolve conflicts
    • push final branch version

3) don't use gui clients except history browsing

why should never rebase public branches

let's imagine following situation: there branch named feature created master.

both , colleague have branch , work on (that's mean "public" branch).

1) , colleague have feature branch

... o ---- o ---- ---- b      origin/master                    \                     ----        origin/feature                      \                       --- c     your/feature                       \                        \-- d    colleague/feature 

2) rebase feature branch on top of master.

note changed history , have new c' commit on your/feature branch , not derived origin/feature anymore:

... o ---- o ---- ---- b ---         origin/master                    \     \                     ---   \            origin/feature                      \     \                       \     --- c'     your/feature                        \                         \-- d          colleague/feature 

3) have branch isn't related origin/feature , colleague/feature. if created new branch , moved changes onto it.

if try to push feature branch origin repository, git tell branches have diverged.

you still can use --force push , history this:

... o ---- o ---- ---- b ---         origin/master                    \     \                     \     \       /--  origin/feature                      \     \     /                       \     --- c' --  your/feature                        \                         \-- d          colleague/feature 

see happened?

now colleague's branch disconnected yours , origin, have problems pushing / pulling changes.

at point can try use --force , overwrite variant of feature branch.

this way can end losing changes. well, nothing lost , can restored, may complex deal such situations.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -