You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
thengit status to see if you don't knowthe merge conflicts yet
git merge but will fail, onlyfor purpose of prompting it in VSCodethen, I usually accept both changes and fix manually
git add -A or specific conflict file only
git commit -m "<your message>"
git push
2 commits are in remote main history,local commit + merge commit
Git Rebase
edit files locally
git add -A or specific conflict file only
git commit -m "<your message>"
git fetch
thengit status to see if you don't knowthe merge conflicts yet
git rebase but will fail, only to automaticallypromp you to VSCode, I usuallyaccept both changes and fix manually
git add -A or specific conflict file only
git commit -m "<your message>"
git rebase --continue, if that is thelast conflict to be edited, this will besuccessful
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
git checkout main
git pull
git checkout <the-target-branch>
git pull origin main
git push
the short way
exactly in your branch( no need to switch branches )
git pull origin main
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
git add -A
git commit -m '<your message>'
git checkout main
git fetch -p origin
git merge origin
git checkout <target-branch>
git merge main
settle the conflict if there is anythengit add -A thengit commit -m 'your message'
git push
the short way, in your active branch
git fetch origin main
git merge origin/main
settle the conflict if there is anythengit add -A thengit commit -m 'your message'
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
git add -A
git commit -m '<your message>'
git checkout main
git fetch -p origin
git rebase origin
git checkout <target-branch>
git rebase main
settle the conflict if there is anythengit add -A thengit commit -m 'your message'
git rebase --continue
if there are no conflicts left,the rebase will be completed thengit push
the short way, in your active branch
git fetch origin main
git rebase origin main
settle the conflict if there is anythengit add -A thengit commit -m 'your message'
git rebase --continue
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 !