git pull when no changes made in local
- edit files locally
git add -A
or specific conflict file onlygit commit -m "<your message>"
git fetch
- then
git status
to see if you don't know the merge conflicts yet git merge
but will fail, only for purpose of prompting it in VSCode then, I usually accept both changes and fix manuallygit add -A
or 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 -A
or specific conflict file onlygit commit -m "<your message>"
git fetch
- then
git status
to see if you don't know the merge conflicts yet git rebase
but will fail, only to automatically promp you to VSCode, I usually accept both changes and fix manuallygit add -A
or 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 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 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 -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 any
then
git 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 any
then
git add -A
thengit 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 -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 any
then
git add -A
thengit 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 main
git rebase origin main
- settle the conflict if there is any
then
git add -A
thengit commit -m 'your message'
git rebase --continue
- if there are no conflicts left,
the rebase will be completed then
git push