How to fix Indirect ancestor commits in Gerrit - gerrit

I have branch with 10 commits (using Gerrit), after going through code review (across the whole chain) I have fixed each commit via git rebase --i HEAD~<commit_idex>. After finishing the rebase interactive (I did it couple of times, and pushed a lot of changes with commit --amend, also i have ran into merge conflicts and I have resolved them), I was surprised to find out, that 3 commits from the top (including the HEAD), marked by Gerrit as Indirect ancestor.
What does that mean and how can I fix it before merging the code into master ?

Certainly, these 3 commits are based on old patchsets of the parent changes, like in the following example:
master
\
\-- A1 --- B1 --- C2
\
\-- C1 --- D1 --- E1
Commits A, B, and C are ready to be submitted, but commits D and E aren't, because commit D is based on an old patchset of commit C.
You must rebase the problematic commits to the newest parent patchsets (first commit D, then commit E) to get this:
master
\
\-- A1 --- B1 --- C2 --- D2 --- E2
\
\-- C1 --- D1 --- E1

Related

Bitbucket submodule update periodically fails but clone doesn't

After cloning a repo in Bitbucket that has submodules, once in a few weeks, following happens for several minutes to several hours:
One of the repositories that is a submodule fails to clone with git submodule update --init --jobs 16 --force. When that happens, it's only one out of all the submodules and it's that same repository until the problem goes away. Next time it will be a different one. When that happens, repository clones work fine with git clone - just the submodule way of cloning that fails.
Number of jobs doesn't matter. --jobs=1 works in the same way.
Git version doesn't matter (tried several different ones).
Bitbucket access log isn't helpful. Entries are same pretty much for both success and failure in atlassian-bitbucket-access.log.
The URL in .gitmodules is correct and no proxy server is being used.
Bitbucket version is 5.16.5
The git error: fatal: the remote end hung up unexpectedly
The log entry in Bitbucket access log:
10.128.146.44 | ssh | i#WMYO89x939x37670172x5 | username | 2022-05-12 15:39:00,596 | SSH - git-upload-pack '/project/repo.git' | "SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.8" | - | - | - | - | - | 1fdp8p1 |
10.128.146.44 | ssh | o#WMYO89x939x37670172x5 | username | 2022-05-12 15:39:00,629 | SSH - git-upload-pack '/project/repo.git' | "SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.8" | 0 | 1269 | 438198 | cache:hit, clone, protocol:1, ssh:user:id:951 | 33 | 1fdp8p1 |
While trying out the https cloning, following error comes up:
fatal: remote error: upload-pack: not our ref <a git hash here that points to a commit abject>

Is there any way to clone only particular folder/files in the plastic SCM instead of entire branch?

I want to copy/clone only particular files from repo.
I tried many ways using cm cmd line executable of plastic.
cm getfile --help
Downloads the content of a given revision.
Usage:
cm getfile | cat <revspec> [--file=<output_file>] [--debug]
[--symlink] [--raw]
revspec Object specification. (Use 'cm help objectspec' to learn
more about specs.)
Options:
--file File to save the output. By default, it is printed on the
standard output.
--debug When a directory specification is used, the command
shows all the items in the directory, its revision id
and file system protection.
--symlink Applies the operation to the symlink and not to the
target.
--raw Displays the raw data of the file.
Examples:
cm cat myfile.txt#br:/main
(Obtains the last revision in branch 'br:/main' of 'myfile.txt'.)
cm getfile myfile.txt#cs:3 --file=tmp.txt
(Obtains the changeset 3 of 'myfile.txt' and write it to file 'tmp.txt'.)
cm cat serverpath:/src/foo.c#br:/main/task003#myrepo
(Obtains the contents of '/src/foo.c' at the last changeset of branch
'/main/task003' in repository 'myrepo'.)
cm cat revid:1230#rep:myrep#repserver:myserver:8084
(Obtains the revision with id 1230.)
cm getfile rev:info\ --debug
(Obtains all revisions in the 'info' directory.)

Not Able to Get Deleted File From Git Commit

I deleted a few files from my rails app using git. They were committed and pushed to Heroku (live). Now, I would like to bring a couple of them back, but I'm having trouble doing so. I've been using git for awhile and not sure what I'm doing wrong. I've checked a couple of git pages to be sure this should work.
The files are not in my local repository, but are in git. Git lists them (showing one in my example), but wont let me retrieve them.
I found the commit and the following shows the file in that logged commit:
jdc44#jdc44-Kudu:~/Websites/myapp$ git diff-tree --no-commit-id --name-only -r 9c88a26ade871
...
app/models/fitness/weight.rb
...
Trying to revert the weight.rb file:
jdc44#jdc44-Kudu:~/Websites/myapp$ git checkout 9c88a26ade871 -- app/models/fitness/weight.rb
error: pathspec 'app/models/fitness/weight.rb' did not match any file(s) known to git
Trying to see if I can show the file:
jdc44#jdc44-Kudu:~/Websites/myapp$ git show 9c88a26ade871:app/models/fitness/weight.rb
fatal: Path 'app/models/fitness/weight.rb' does not exist in '9c88a26ade871'
edited
jdc44#jdc44-Kudu:~/Websites/myapp$ git diff-tree -r 9c88a26ade871
9c88a26ade8719069ecd852b27a6bb354a4915f2
:100644 000000 ba4631114edea7c66e8f87109dc6e65fb95b7a6c 0000000000000000000000000000000000000000 D app/controllers/fitness/weights_controller.rb
:100644 000000 cfca94348c82c4a6fab1c789245582cc3086f786 0000000000000000000000000000000000000000 D app/models/fitness/weight.rb
:100644 000000 4963ad7f7939f74606b5356e264dc20c1382165b 0000000000000000000000000000000000000000 D app/views/fitness/weights/_form.html.erb
:100644 000000 9c3f9b7f3f7177d7ba4b5609f3aa5c0769b7d1e1 0000000000000000000000000000000000000000 D app/views/fitness/weights/create.html.erb
:100644 000000 3b9e22e45116d15eab5a494ce342307cac1ce405 0000000000000000000000000000000000000000 D app/views/fitness/weights/delete.html.erb
:100644 000000 8e3ec02483b68e8f5a2e8de23f569dbd359d3d95 0000000000000000000000000000000000000000 D app/views/fitness/weights/destroy.html.erb
:100644 000000 d59b3be0408d467bcedf1ac43e82916e338d30d9 0000000000000000000000000000000000000000 D app/views/fitness/weights/edit.html.erb
:100644 000000 84a1dd6e73c35a612e4e52476d440fd7a659b657 0000000000000000000000000000000000000000 D app/views/fitness/weights/index.html.erb
:100644 000000 4980c3adecc0b86528d99f7828c5369f185a1ba2 0000000000000000000000000000000000000000 D app/views/fitness/weights/new.html.erb
:100644 000000 eb61383cc1e256e386357930d9db8bf88379ad2c 0000000000000000000000000000000000000000 D app/views/fitness/weights/show.html.erb
:100644 000000 43f9c0adea7cff97c240bd02db495e908231bfd4 0000000000000000000000000000000000000000 D app/views/fitness/weights/update.html.erb
Each commit in Git is a complete snapshot of all the files at that moment. 9c88a26ade871 does not have the file app/models/fitness/weight.rb because that's the commit where you deleted it.
You need to get it from the commit before you deleted it. 9c88a26ade871^. See gitrevisions.
git checkout 9c88a26ade871^ -- app/models/fitness/weight.rb
Or use the simpler git restore (checkout was split into restore and switch).
git restore --source 9c88a26ade871^ app/models/fitness/weight.rb

Plastic SCM Branch Visual Bug

I was trying to delete an empty branch that accidentally got created, when to my surprise it said that this weird little branch had a child! Which was strange, because visually it did not appear to have a child, it didn't even have any change-sets in it. I looked into its children and somehow a branch that was split off from this empty branches parent somehow became the child of the empty branch! I was wondering if there was a way to move this child back to the parent of the empty where it belongs or should I just resign myself to having a weird outlier?
What branch explorer visually says I have:
----main branch---|ch1|---------|ch2|---------|ch5|
| \ /
| \
| |ch3|---real branch---|ch4|
|
\
\----empty branch---
what I actually have:
----main branch---|ch1|----------------------|ch2|--------------------|ch5|
\ /
\ /
\ /
\----empty branch---\ /
\ /
|ch3|---real branch---|ch4|
what I want:
----main branch---|ch1|---------|ch2|--------|ch5|
\ /
\ /
|ch3|---real branch---|ch4|

How to restore git master, which was replaced by another master

I've made something wrong to my own git repository argh :/
Before I had 3 branches: master, layout and masscreate (all from me).
But now, I don't know what I've done wrong, my git master is the master of the rails repository?!?
When I switch to my master branch and make a git status, it shows me:
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 25732 and 239 different commit(s) each, respectively.
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
# ... some changes from my own code
I don't know whats happening if I commit now?!
I use GitX and it never showed me the rails branches.. But now there are beside my own branches, all the rails branches.. :/
EDIT:
git reflog --all shows me
a979775 refs/heads/masscreate#{0}: commit: Updated bitcoin client, removed unnecessary files, added mass create feature, updated gems
d2e2fb8 refs/heads/masscreate#{1}: commit: First commit
74fbbca refs/heads/3-1-stable#{0}: fetch --force --quiet --tags git://github.com/rails/rails.git refs/heads/*:refs/heads/*: storing head
4a065d5 refs/heads/master#{0}: fetch --force --quiet --tags git://github.com/rails/rails.git refs/heads/*:refs/heads/*: forced-update
5419222 refs/heads/layout#{0}: commit: First layout commit - not working
c42120e refs/heads/masscreate#{2}: branch: Created from master
11b0804 refs/heads/layout#{1}: commit: Test commit (with logo)
954297b refs/heads/layout#{2}: branch: Created from master
fd67735 refs/heads/3-0-stable#{0}: fetch --force --quiet --tags git://github.com/rails/rails.git refs/heads/*:refs/heads/*: storing head
afd7140 refs/heads/serializers#{0}: fetch --force --quiet --tags git://github.com/rails/rails.git refs/heads/*:refs/heads/*: storing head
ba70812 be6527f 7bf12a1 05386ce 471e1f1 7f60202 f40bbc9 57a01f3 162e13d 3c6cbad f8beca0 4f2c238 cf4d166 14e2fe2 fc9b521 aa11f73 9257a21 c6d13b6 d9d1bb2 db8db4a 188d21c 0ad5040 87
633a569 a19ee5c 66c3e31 f9b642c 09ad48f 4f15f39 b45dfc7 3480d97 fb4747b e0c03f8 e0774e4 refs/heads/2-3-stable#{0}: fetch --force --quiet --tags git://github.com/rails/rails.git r
dea5a10 c238ba0 11dafea bb99aa1 2330c0c ae69c4c 29d0ce0 4b4e67f f3f5a8f ebf0cc4 927d3c2 d8c6bab 0c3bdc0 4eac844 dbd72be 282ee95 92d3b51 073d9ff 9e9b127 388f09c 0ab65e8 458128d 35
ad16115 5e61d0b 15e2b58 refs/heads/3-0-9#{0}: fetch --force --quiet --tags git://github.com/rails/rails.git refs/heads/*:refs/heads/*: storing head
014008d d2b1340 7b04e50 a7039df 677df61 7f96566 b4b27a3 40dd641 95905c5 1f813d9 055a88d fa55293 f6fe174 b869b8c 71d7610 991e388 6cfd1c7 9267a43 190101e 8624996 5daef25 aeb7beb e5
d846f4b 6766caf e149861 f5f020b b7ea35d f8f00cc 2cbd024 da5122e 296ca01 ea8b05c 54f5fb5 96711aa a995911 654514a 69b25eb 8d758d8 645f138 a2a3413 377b15a b3b747d 1f02e3e 75fb26a f8
79abb70 1c079c5 f0c09f7 99cfdba d387a59 656e7b0 1d864e8 b102e60 d485633 177666e f236dbf 17c9efb c77bdc0 f505565 89252c4 da1ee0e 83f257f 872a9c1 3cbfc8c 5a6927e b648286 d79e284 65
e019587 0acc6bd 92537b8 c6c46e1 280a870 51f5209 af41d55 3b0f917 07fde1a 3e33592 3937296 389d15e 7a152ab 944b4d5 4f04452 9556e9c 9dfc215 49e7555 bb626e7 0675047 d0635b6 b14b058 ce
e9020b4 1c4db4d 18dde7b e6bc818 cb9e501 d907f3c 30264bb d7a5638 a9b4b5d 92e6255 3575782 ac07da8 f323a8f 284ca81 454ec93 b356172 16e5d15 4ac7196 3e24e9e 4c323bc 9bf5cdd bd3cdee a0
ee0b92e 631e23e cd44023 51414a0 1df3b65 9643243 ac86923 ea25224 08ef06d 2b4de66 4f7bdc8 e62b576 d9870d9 52f09ea 05bcb8c d55406d 5f1ea2a 30bba95 1193709 9f773d6 60da34b 933adce 0d
c6cb5a5 refs/heads/2-2-stable#{0}: fetch --force --quiet --tags git://github.com/rails/rails.git refs/heads/*:refs/heads/*: storing head
bcbff10 7a3f05f d152171 c4458b3 8aedd72 b7594a0 f1a15c2 115eedb ef79b91 bf24fe8 3ef6937 52c4755 8f88a28 9d87f41 421e06f 77e1a99 15e7134 3c6c240 100ab5b 1a05125 bbcdc86 a9163b5 d2
f5ed5c3 96183e0 5a898e1 11508db 002985f 25acd19 7963c30 bc821a5 22782e2 3fb493c 01ab6f9 aa508c9 37d7802 c7aea81 11558a1 72545da a2c52f1 43215de 959f857 f07cbec ab1a661 9c53e82 f3
588ac71 0a41ece c6db348 dbe0802 fca617a c40856c 23303d6 017840b a0ca3d1 23f6e51 ea2ad26 92f4cca dd55830 c017041 7ce1539 82a58ab 90176a6 c924068 bee4147 4b21dfe c11ba42 21063e5 22
5bf3294 8a09ea6 7f7480f 3cb5375 aa31a25 bfbdeea c6843e2 7d04a4b a7988fc 75b32a6 070c242 075f8b7 547199e 54250a5 52e526a f6d7a4d 201f373 8cc7463 5360014 227e1ca aeaa468 9e6e648 01
74206ae 774f596 5b1f4c5 ec017e1 5d979de e535b45 3570f3e 3568c5c ddadcc7 5de2e0d 24610c9 08fb1c4 0706bdc 5d7ad7b 22b020d 2de3646 f45714b 8e7a64d a447f76 6949d6f 0428917 6e4e95b 79
095cf91 a32eeeb 38d65b0 fb74a1b 26306f9 896475c 0489f0c 670281c af5b12c e1b1096 2ea1d68 4f37b97 91f65b7 7a48cd6 8a2cfe9 aeab739 47aebac b7c1fbc 1a0f822 314e18a 2ae84e0 c531bd6 ab
21c75e5 cae1d96 db4f421 8bbabd4 f254616 23e58a0 5457770 1a59aa5 4a643f6 25e139e e7ebd65 3025ff2 2920bd2 4e3ecec 1d5ea18 86cb0a6 4ff26f5 191ffc9 3028ca5 f3fd2b1 c55120c 6f0b012 c7
First, if you're concerned about losing any uncommitted work, save it somewhere else.
The git reflog command is a history of the changes made to the current branch head:
git reflog
will show, in reverse chronological order (newest at the top), every time the current branch head changed to a new commit id. From this list, you can choose which one you want, and use git reset --hard abc123 to reset the current branch head to that commit.
You can read more about the reflog at reflog, your safety net.
I found now a solution:
checked out the last working copy from github (here named as
backup)
compared the backup with a directory comparing tool
removed all references to the rails repository I found and set the .git/refs/head/master commit-hash to my last commit hash
And now it works again..
argh..

Resources