Search code examples
gitmergegit-branchprettier

Your branch and origin/master have diverged


I know others have asked this question but I want to understand what it means.I am still learning git.

I was on the branch sample-tests I did the following :

git checkout master- I switched to master branch

git pull - I did this to pull all the remote code to my local, so that I have a updated local code.

and I see this:

` On branch master Your branch and 'origin/master' have diverged, and have 2 and 40 different commits each, respectively. (use "git pull" to merge the remote branch into yours)

All conflicts fixed but you are still merging. (use "git commit" to conclude merge)

Changes to be committed:

    modified:   .eslintrc.js
    modified:   README.md
    modified:   cypress.json
    modified:   cypress/integration/SaveFormTest.js
    new file:   cypress/integration/SaveFormTest_orig.js
    modified:   cypress/support/commands.js
    new file:   cypress_old.json
    new file:   cypress_original.json
    modified:   jest.config.js
    modified:   package.json
    modified:   src/App.tsx
    modified:   src/api/requests.js
    modified:   src/components/AddressInput/AddressInput.tsx
    modified:   src/components/AddressInput/constants.ts
    modified:   src/components/FileUpload/FileUpload.styles.tsx
    modified:   src/components/FileUpload/FileUpload.tsx
    modified:   src/components/FileUpload/FileUpload.types.ts
    modified:   src/components/FileUpload/constants.ts
    new file:   src/components/FileUpload/utility.ts
    modified:   src/components/FileUploadTile/FileUploadTile.js
    modified:   src/components/FileUploadTile/UploadButton/UploadButton.js
    modified:   src/components/FormFieldsGenerator/FormFieldsGenerator.styles.tsx
    modified:   src/components/FormFieldsGenerator/FormFieldsGenerator.tsx
    modified:   src/components/FormFieldsGenerator/FormFieldsGenerator.types.ts
    modified:   src/components/FormFieldsGenerator/constants.ts
    modified:   src/components/FormFieldsGenerator/utility.ts
    modified:   src/components/FormPageTemplate/FormPageTemplate.tsx
    modified:   src/components/FormPageTemplate/FormPageTemplate.types.ts
    modified:   src/components/FormPageTemplate/FormPageTemplate.validation.ts
    new file:   src/components/FormQuestionDialogue/helpers.ts
    new file:   src/components/InputFormatted/InputCurrency.tsx
    new file:   src/components/InputFormatted/InputFormatted.styles.tsx
    new file:   src/components/InputFormatted/InputFormatted.tsx
    new file:   src/components/InputFormatted/InputFormatted.types.ts
    new file:   src/components/InputFormatted/index.ts
    new file:   src/components/ResourceDropdown/ResourceDropdown.styles.tsx
    new file:   src/components/ResourceDropdown/ResourceDropdown.tsx
    new file:   src/components/ResourceDropdown/ResourceDropdown.types.ts
    new file:   src/components/ResourceDropdown/index.ts
    modified:   src/components/Table/Table.styles.tsx
    modified:   src/components/Table/Table.tsx
    modified:   src/components/Table/Table.types.ts
    modified:   src/components/TopPanel/TopPanel.js
    deleted:    src/components/TopPanel/TopPanel.test.js
    modified:   src/config/messages/en.js
    modified:   src/constants/constants.js
    modified:   src/constants/propTypes.ts
    new file:   src/containers/AgentResources/AgentResources.styles.tsx
    new file:   src/containers/AgentResources/AgentResources.tsx
    new file:   src/containers/AgentResources/index.ts
    modified:   src/containers/UserWidget/UserWidget.js
    deleted:    src/containers/UserWidget/UserWidget.test.js
    modified:   src/graphql/client.ts
    deleted:    src/graphql/errorLink.ts
    deleted:    src/graphql/httpLink.ts
    new file:   src/gra

Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory)

    modified:   cypress.json
    modified:   cypress/support/commands.js`

What does this mean: On branch master Your branch and 'origin/master' have diverged, and have 2 and 40 different commits each, respectively.

Obviously I am on the local master branch. Does it mean that my local master branch is not the same as the remote master branch?

Should I do:

git add .

git commit -m "message". to resolve this? Also should I be doing this on the current master branch I am on?

I resolved the conflicts, staged and tried committing. However I think the commit didnt go through, I think because I am getting the following error. Is the error in cypress.json?What is the error that prettier --write found?

` renukaalurkar$ git commit -m "resolving errors"

husky > pre-commit (node v12.14.1)

↓ Stashing changes... [skipped]

→ No partially staged files found...

 ❯ Running tasks...

  ❯ Running tasks for *.{js,json,css,md}
  
   ✖ prettier --write

    git add

  ✖ prettier --write found some errors. Please fix them and try 

  committing again.

.eslintrc.js 48ms

README.md 89ms

cypress.json 8ms

cypress/integration/SaveFormTest.js 58ms

cypress/integration/SaveFormTest_orig.js 23ms

 cypress/support/commands.js 20ms

 cypress_original.json 5ms

 jest.config.js 7ms

 src/api/requests.js 28ms

 src/components/FileUploadTile/FileUploadTile.js 22ms

 src/components/FileUploadTile/UploadButton/UploadButton.js 15ms

 src/components/TopPanel/TopPanel.js 37ms

 src/config/messages/en.js 11ms

 src/constants/constants.js 14ms

 src/store/user/reducers.test.js 20ms

[error] cypress_old.json: SyntaxError: Unexpected token (1:7)

[error] > 1 | b0VIM 8.1��B^.�rrenukaalurkarRenukas-

 MBP~renukaalurkar/Documents/cypress_tests_renuka/KW-Offers- 

FE/cypress.jsonutf-8

[error]     |       ^

[error]   2 | U3210#"! Utpada������w\E$������} "defau}} 

 "defaultCommandTimeout": 100000 }, 

  "test_admin_pass":${TEST_ADMIN_PASS}   "test_admin":${TEST_ADMIN}, 

 "test_tc_pass":${TEST_TC_PASS}, "test_tc":${TEST_TC},   

  "test_pass":${TEST_PASS},       "test_user":${TEST_USER},  

"password":${PASSWORD}, "user_name",    "host":"https://app.kw-

offers.master.kw-offers-dev.com/",  "env":{{

husky > pre-commit hook failed (add --no-verify to bypass)

Renukas-MacBook-Pro:KW-Offers-FE renukaalurkar$ git pull

error: You have not concluded your merge (MERGE_HEAD exists).

hint: Please, commit your changes before merging.

fatal: Exiting because of unfinished merge.

Renukas-MacBook-Pro:KW-Offers-FE renukaalurkar$ 

`


Solution

  • Seems like you have 2 local commits and 40 on remote branch. Git tried to resolve the differences, but it failed, so uou hav conflicts in some files now.

    I would check these two files:

    cypress.json
    cypress/support/commands.js
    

    Fix any problems you find there and then stage them. After that git commit.