Stream: general

Topic: Git Rebase Help

luigishat (Oct 05 2019 at 22:56, on Zulip):

I'm Currently working on this PR ( and I'm having trouble doing as "Bjorn3" says. Can somebody tell me how to git rebase my previous commits so I can push my new commit which I ran ./ test /src/doc/rust-ui --bless ?

davidtwco (Oct 05 2019 at 23:10, on Zulip):

Let me try and understand what you're trying to do. You've got a new commit with the changes from ./ test src/doc/rustdoc-ui --bless and you want to rebase your commits atop master?

davidtwco (Oct 05 2019 at 23:12, on Zulip):


luigishat (Oct 06 2019 at 03:26, on Zulip):

The first part is right. What I'm trying to do is push these changes after ./ ... but git says there are none. So I was told to "rebase" all my previous commits and push my latest too see if that would work.

luigishat (Oct 06 2019 at 03:27, on Zulip):


davidtwco (Oct 06 2019 at 08:17, on Zulip):

@luigishat can you print the output of git status and git log (perhaps only for the last handful of commits, in a gist or pastebin).

luigishat (Oct 07 2019 at 05:24, on Zulip):

The git log is quite small so here is the paste

~/D/R/rust [cmp_fix] » git log                                          22:19:29
commit 4b57287baea7d0d79c3645f0cd22f7a0bbe6da09 (HEAD -> cmp_fix, origin/cmp_fix)
Author: Caleb Behunin <>
Date:   Sun Sep 8 22:17:10 2019 -0700

    Reset Branch and Made Changes

commit d760df5aea483aae041c9a241e7acacf48f75035 (origin/master, origin/HEAD, master)
Merge: 783469ca09 53f4734794
Author: bors <>
Date:   Sun Aug 25 08:06:06 2019 +0000

    Auto merge of #63874 - spastorino:places-drive-by-cleanups, r=Centril

    Places drive by cleanups

    Small fixes of things meanwhile I was doing the box part of Place 2.0, based on @centril reviews.

commit 783469ca09005d135c3204a55069707d1cd705a9
Merge: 9267119019 5a7e1cb46a
Author: bors <>
Date:   Sun Aug 25 04:26:26 2019 +0000
luigishat (Oct 07 2019 at 05:25, on Zulip):

and git status

~/D/R/rust [cmp_fix] » git status                                       22:24:21
On branch cmp_fix
Your branch is up to date with 'origin/cmp_fix'.

nothing to commit, working tree clean


davidtwco (Oct 07 2019 at 08:31, on Zulip):

So, the commit hash you have there, 4b57287baea7d0d79c3645f0cd22f7a0bbe6da09, matches what is the latest on your PR, so I think Git is correct in thinking there's nothing new to push.

davidtwco (Oct 07 2019 at 08:34, on Zulip):

I think the issue is that when your PR is tested by the CI, then it gets merged with master first, and when that happens, there are new/changed rustdoc tests that your changes will affect. Because your local branch isn't based on the most recent master, you don't have the new/changed rustdoc tests and so telling to update the output ./ test src/doc/rustdoc-ui --bless doesn't do anything! Here's what you want to do:

git checkout master
git pull upstream master
git checkout cmp_fix
git rebase master
./ test src/doc/rustdoc-ui --bless

Then commit and push as normal. If you don't have a remote named upstream, and the second command fails, then do git remote add upstream

davidtwco (Oct 07 2019 at 08:34, on Zulip):


Paul Faria (Oct 07 2019 at 12:45, on Zulip):

This could also go faster with just git checkout cmp_fix && git rebase upstream/master. Depends on if you want a local copy of rust-lang's master branch or not

luigishat (Oct 08 2019 at 02:33, on Zulip):

@davidtwco Ok so I set my branch too master using "git checkout master" but when I try to "git pull upstream master" I get

remote: Not Found
fatal: repository '' not found

Any thoughts ? ( I apologize I'm still very new too git's more advanced functionality)

luigishat (Oct 08 2019 at 02:37, on Zulip):

Would I do something like "git remote set-url origin" ?

davidtwco (Oct 08 2019 at 07:04, on Zulip):

@luigishat your remote url should be the url to the upstream repository, not the issue. Try:

git remote remove upstream
git remote add upstream
luigishat (Oct 09 2019 at 02:53, on Zulip):

Ok running " ./ test src/doc/rustdoc-ui --bless". Thanks for helping me out @davidtwco

luigishat (Oct 09 2019 at 03:10, on Zulip):

Also what does this line do "git rebase master" I can't seem to get my head wrapped around rebase in general. Does it squish all of the previous commits and put mine first ?

luigishat (Oct 09 2019 at 04:18, on Zulip):

Any need to worry about these ? @davidtwco This occurs after running git rebase master

~/D/R/rust [cmp_fix] » git rebase upstream/master                       21:15:57
Current branch cmp_fix is up to date.
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
warning: The last gc run reported the following. Please correct the root cause
and remove .git/gc.log.
Automatic cleanup will not be performed until the file is removed.

warning: There are too many unreachable loose objects; run 'git prune' to remove them.
Laurențiu Nicola (Oct 09 2019 at 06:44, on Zulip):

Nah, don't worry. git gc just does a bit of house cleaning. It's complaining that you have a bunch of "old" commits that are no longer accessible

Laurențiu Nicola (Oct 09 2019 at 06:45, on Zulip):

git rebase upstream/master basically takes what's in upstream/master, then applies each of your commit on top of that. It's nice because you get a linear history when you finally merge the branch.

Laurențiu Nicola (Oct 09 2019 at 06:46, on Zulip):

It can also edit the history (change commit contents or message, reorder them, squash multiple commits into a single one), but that's usually done as an "interactive rebase", git rebase -i

Laurențiu Nicola (Oct 09 2019 at 06:49, on Zulip):

So if you notice a mistake in one of previous your commits, you can just git commit -am "fix stuff", then git rebase -i HEAD~5 and you'll get a list of the last five commits. In there you can move your "fix stuff" commit earlier, then mark it as "fixup" or "squash", meaning it will be combined with the previous one.

Laurențiu Nicola (Oct 09 2019 at 06:51, on Zulip):

It's usually fine to change history like that on a feature branch like your PR, but it's considered bad practice to do it on master, and some people might complain. And it's somewhat dangerous, in that if you misuse git rebase you can lose your work (you're not going to lose them, see git reflog, but that's a story for another day).

Last update: Jun 04 2020 at 18:30UTC