git: Add support for git pull with rebase (#41117)

- Adds a new action `git::PullRebase` which adds `--rebase` in the final
command invoked by existing Git-Pull implementation.
- Includes the new action in "Fetch/Push" button in the Git Panel
(screenshot below)
- Adds key-binding for `git::PullRebase` in all three platforms,
following the existing key-binding patterns (`ctrl-g shift-down`)
- Update git docs to include the new action.

Sidenote: This is my first ever OSS contribution

Screenshot:

<img width="234" height="215" alt="image"
src="https://github.com/user-attachments/assets/713d068f-5ea5-444f-8d66-444ca65affc8"
/>

---

Release Notes:

- Git: Added `git: pull rebase` for running `git pull --rebase`.
This commit is contained in:
Sathiyaraman M
2025-11-04 16:41:06 +00:00
committed by GitHub
parent 9f580464f0
commit 982f2418f4
11 changed files with 79 additions and 46 deletions
+2 -1
View File
@@ -2219,7 +2219,7 @@ impl GitPanel {
.detach();
}
pub(crate) fn pull(&mut self, window: &mut Window, cx: &mut Context<Self>) {
pub(crate) fn pull(&mut self, rebase: bool, window: &mut Window, cx: &mut Context<Self>) {
if !self.can_push_and_pull(cx) {
return;
}
@@ -2254,6 +2254,7 @@ impl GitPanel {
repo.pull(
branch.name().to_owned().into(),
remote.name.clone(),
rebase,
askpass,
cx,
)
+10 -1
View File
@@ -126,7 +126,15 @@ pub fn init(cx: &mut App) {
return;
};
panel.update(cx, |panel, cx| {
panel.pull(window, cx);
panel.pull(false, window, cx);
});
});
workspace.register_action(|workspace, _: &git::PullRebase, window, cx| {
let Some(panel) = workspace.panel::<git_panel::GitPanel>(cx) else {
return;
};
panel.update(cx, |panel, cx| {
panel.pull(true, window, cx);
});
});
}
@@ -597,6 +605,7 @@ mod remote_button {
.action("Fetch", git::Fetch.boxed_clone())
.action("Fetch From", git::FetchFrom.boxed_clone())
.action("Pull", git::Pull.boxed_clone())
.action("Pull (Rebase)", git::PullRebase.boxed_clone())
.separator()
.action("Push", git::Push.boxed_clone())
.action("Push To", git::PushTo.boxed_clone())