1

In GitKranken, I often use Pull (rebase) feature to get my code updated with teamates's recent updates.

I'm looking for git command syntax for that - my goal is to quickly update the code right in working console i.e. without having to open GitKraken menu.

My google search results me this

$ git pull --rebase origin master

though the command claims for unstaged/uncommitted changes

$ git pull --rebase origin master
error: Cannot pull with rebase: You have unstaged changes.
error: Additionally, your index contains uncommitted changes.

(snapshots) Pull (rebase) feature in GitKraken

enter image description here

Community
  • 1
  • 1
Nam G VU
  • 33,193
  • 69
  • 233
  • 372

2 Answers2

1

GitKraken doesn't use the command line, it actually just uses git directly, so it has some options that aren't possible in the command line. The reason git doesn't allow this is because there could be conflicts that you have to deal with during the rebase, but I imagine GitKraken has some state information to deal with that eventuality. What you should be doing if you have uncommitted changes is this:

git stash

git pull --rebase (or git config --global pull.rebase true to make a pull rebase by default)

git stash pop (after handling any conflicts from the rebase)

If you are determined to do this in one step, which you shouldn't, you can make an alias like this:

git config --global alias.pullsketchy 'git stash && git pull --rebase && git stash pop'

In all likelihood gitkraken is doing something like this under the hood.

suddjian
  • 1,986
  • 2
  • 16
  • 25
1

git stash && git pull --rebase && git stash pop

Since Git 2.9, no need for aliases:

Type in your repo:

git config pull.rebase true
git config rebase.autoStash true

Then a simple git pull is enough (to stash, fetch, rebase, unstash).

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250