git pull when no changes made in local
- edit files locally
git add -Aor specific conflict file onlygit commit -m "<your message>"git fetch- then
git statusto see if you don't know the merge conflicts yet git mergebut will fail, only for purpose of prompting it in VSCode then, I usually accept both changes and fix manuallygit add -Aor specific conflict file onlygit commit -m "<your message>"git push
2 commits are in remote main history, local commit + merge commit
- edit files locally
git add -Aor specific conflict file onlygit commit -m "<your message>"git fetch- then
git statusto see if you don't know the merge conflicts yet git rebasebut will fail, only to automatically promp you to VSCode, I usually accept both changes and fix manuallygit add -Aor specific conflict file onlygit commit -m "<your message>"git rebase --continue, if that is the last conflict to be edited, this will be successfulgit push
1 commit only in remote main history
My typical workflow is I will start
in main editing the files, but
I will not commit in there
git switch -c 'new-branch-name'
then
git add -A
git commit -m '<your message>'
then git push once your branch
is ready
git push -u origin <same-branch-name-as-local>
use this when there are no changes in your local branch but remote main has commits and your branch is outdated
the long way
git checkout maingit pullgit checkout <the-target-branch>git pull origin maingit push
the short way
exactly in your branch ( no need to switch branches )
git pull origin maingit push
git pull origin main fetches commits from
the remote main ( the GitHub repo main )
then it merges local main into the branch
you are currently in
please do note that your local main is still behind but that's not a problem when your main branch is stale,
to update the local main,
git checkout main
git pull
all will be up to date
finally, the remote branch will be updated, no commits behind master
when you are actively editing your branch, then another developer pushed in remote main you need to update yours too, save your changes first in your active local branch
git add -Agit commit -m '<your message>'git checkout maingit fetch -p origingit merge origingit checkout <target-branch>git merge main- settle the conflict if there is any
then
git add -Athengit commit -m 'your message' git push
the short way, in your active branch
git fetch origin maingit merge origin/main- settle the conflict if there is any
then
git add -Athengit commit -m 'your message' git push
when you are actively editing your branch, then another developer pushed in remote main you need to update yours too, save your changes first in your active local branch
git add -Agit commit -m '<your message>'git checkout maingit fetch -p origingit rebase origingit checkout <target-branch>git rebase main- settle the conflict if there is any
then
git add -Athengit commit -m 'your message' git rebase --continue- if there are no conflicts left,
the rebase will be completed then
git push
the short way, in your active branch
git fetch origin maingit rebase origin main- settle the conflict if there is any
then
git add -Athengit commit -m 'your message' git rebase --continue- if there are no conflicts left,
the rebase will be completed then
git push