Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

the never ending headache of git merge conflicts, so here we are to solve it !

License

NotificationsYou must be signed in to change notification settings

jdevfullstack-tutorials/git-merge-resolve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Without Using Branches

Git Pull Only

git pull when no changes made in local

Git Fetch & Merge

  1. edit files locally
  2. git add -A or specific conflict file only
  3. git commit -m "<your message>"
  4. git fetch
  5. thengit status to see if you don't knowthe merge conflicts yet
  6. git merge but will fail, onlyfor purpose of prompting it in VSCodethen, I usually accept both changes and fix manually
  7. git add -A or specific conflict file only
  8. git commit -m "<your message>"
  9. git push

2 commits are in remote main history,local commit + merge commit

Git Rebase

  1. edit files locally
  2. git add -A or specific conflict file only
  3. git commit -m "<your message>"
  4. git fetch
  5. thengit status to see if you don't knowthe merge conflicts yet
  6. git rebase but will fail, only to automaticallypromp you to VSCode, I usuallyaccept both changes and fix manually
  7. git add -A or specific conflict file only
  8. git commit -m "<your message>"
  9. git rebase --continue, if that is thelast conflict to be edited, this will besuccessful
  10. git push

1 commit only in remote main history

Using Branches ( The Typical Way )

Create A Branch First

My typical workflow is I will startinmain editing the files, butI will not commit in there

git switch -c 'new-branch-name'

then

git add -A

git commit -m '<your message>'

thengit push once your branchis ready

git push -u origin <same-branch-name-as-local>

Git Pull Origin Main To A Local Branch

use this when there are no changes inyour local branch but remote main hascommits and your branch is outdated

the long way

  1. git checkout main
  2. git pull
  3. git checkout <the-target-branch>
  4. git pull origin main
  5. git push

the short way

exactly in your branch( no need to switch branches )

  1. git pull origin main
  2. git push

git pull origin main fetches commits fromthe remote main ( the GitHub repo main )then it merges local main into the branchyou are currently in

please do note that your local mainis still behind but that's not a problemwhen your main branch is stale,

to update the local main,

git checkout maingit pull

all will be up to date

finally, the remote branch will be updated,no commits behind master

Git Fetch Then Merge

when you are actively editing your branch,then another developer pushed in remote mainyou need to update yours too, saveyour changes first in your active localbranch

  1. git add -A
  2. git commit -m '<your message>'
  3. git checkout main
  4. git fetch -p origin
  5. git merge origin
  6. git checkout <target-branch>
  7. git merge main
  8. settle the conflict if there is anythengit add -A thengit commit -m 'your message'
  9. git push

the short way, in your active branch

  1. git fetch origin main
  2. git merge origin/main
  3. settle the conflict if there is anythengit add -A thengit commit -m 'your message'
  4. git push

Git Fetch Then Rebase

when you are actively editing your branch,then another developer pushed in remote mainyou need to update yours too, saveyour changes first in your active localbranch

  1. git add -A
  2. git commit -m '<your message>'
  3. git checkout main
  4. git fetch -p origin
  5. git rebase origin
  6. git checkout <target-branch>
  7. git rebase main
  8. settle the conflict if there is anythengit add -A thengit commit -m 'your message'
  9. git rebase --continue
  10. if there are no conflicts left,the rebase will be completed thengit push

the short way, in your active branch

  1. git fetch origin main
  2. git rebase origin main
  3. settle the conflict if there is anythengit add -A thengit commit -m 'your message'
  4. git rebase --continue
  5. if there are no conflicts left,the rebase will be completed thengit push

About

the never ending headache of git merge conflicts, so here we are to solve it !

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project


    [8]ページ先頭

    ©2009-2025 Movatter.jp