Paul Melero
Web Developer
I'm in a (local) repository
./index.js
export default () => { console.log('Hola') }
> git add ./index.js
✅
./index.js
export default () => { console.log('Hola') }
> git commit -m 'add hello'
📼
./index.js
(git push)
./index.js
(git push --set-upstream origin issue/hello)
We created a new "history point" in the linear history of changes.
We want to put our work in top of somebody else's
We want to put our work in top of somebody else's
git merge
Merge
git rebase
Rebasing is the process of moving (or combining) a sequence of commits to a new base commit.
Rebase
git rebase --interactive
p, pick <commit> = use commit
r, reword <commit> = use commit, but edit the commit message
e, edit <commit> = use commit, but stop for amending
s, squash <commit> = use commit, but meld into previous commit
f, fixup <commit> = like "squash", but discard this commit's log message
x, exec <command> = run command (the rest of the line) using shell
b, break = stop here (continue rebase later with 'git rebase --continue')
d, drop <commit> = remove commit
l, label <label> = label current HEAD with a name
t, reset <label> = reset HEAD to a label
m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
create a merge commit using the original merge commit's
message (or the oneline, if no original merge commit was
specified). Use -c <commit> to reword the commit message.
#1
#2
#3
git log
> git fetch > git rebase -i origin/master
> git fetch > git rebase -i origin/master
> git config --global core.editor <editor_name>
> git config --global core.editor "code --wait"
#1
#2
#3
ℹ️ Bare in mind the order of the commits is the opposite as the command
git log
Type ":wq"
Type Enter
#1
#2
#3
Making changes to a commit message
Now your local history diverges from the remote one!
git push origin --force
git push -f
git checkout master
git pull
git checkout -b <feature-branch>
git add
,
git commit
and optionally
git push
)
git fetch
git rebase origin/master
git push -f
❗
Never use it on public branches (main, master, dev...), only your feature branches.
Contrary to a regular merge conflict, in a rebase the order is reversed.
But VS Code "gets it wrong" and the "incomming" is actually our changes in the branch we're in!
git rebase --continue
git rebase --abort
> git add ./index.js
- And then, either:
> git push
- Now, you can create the PR
Profit! 👏🏽
> git end
> git thank-you
Thanks for your help, Joshua Coady!
By Paul Melero
What is Git Rebase and what are the benefits of following a simpler workflow than git-flow