I'm Currently working on this PR (https://github.com/rust-lang/rust/pull/63906) 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 ./x.py test /src/doc/rust-ui --bless ?
Let me try and understand what you're trying to do. You've got a new commit with the changes from
./x.py test src/doc/rustdoc-ui --bless and you want to rebase your commits atop master?
The first part is right. What I'm trying to do is push these changes after ./x.py ... 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 can you print the output of
git status and
git log (perhaps only for the last handful of commits, in a gist or pastebin).
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 <email@example.com> 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 <firstname.lastname@example.org> 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 <email@example.com> Date: Sun Aug 25 04:26:26 2019 +0000 :
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
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.
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 x.py to update the output
./x.py 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 ./x.py 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 https://github.com/rust-lang/rust.git.
This could also go faster with just
git checkout cmp_fix && git rebase upstream/master. Depends on if you want a local copy of
master branch or not
@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 'https://github.com/rust-lang/rust/issues/63551/' not found
Any thoughts ? ( I apologize I'm still very new too git's more advanced functionality)
Would I do something like "git remote set-url origin https://github.com/rust-lang/rust/issues/63906/" ?
@luigishat your remote url should be the url to the upstream repository, not the issue. Try:
git remote remove upstream git remote add upstream https://github.com/rust-lang/rust.git
Ok running " ./x.py test src/doc/rustdoc-ui --bless". Thanks for helping me out @davidtwco
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 ?
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.
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
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.
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
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.
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).