On Fri, Nov 26, 2021 at 10:57:01PM +0100, Uwe Brauer wrote:

[...]
> I meant I should *NOT* have pushed 
> 
> >> commit 89346f81fef27286bd3fb1ed3ddc94a6f3fb560d (origin/copyright, 
> >> origin/copy)
[...]
> >> * commit 66380013003549a6851d4e110b29a5a439e05609
[...]
> In other words I need to remove 
> >> commit 89346f81fef27286bd3fb1ed3ddc94a6f3fb560d (origin/copyright, 
> >> origin/copy)
> >> * commit 66380013003549a6851d4e110b29a5a439e05609
> > If yes, then it's simple: do
> >   $ git push -f origin 66380013003:master
> 
> By that logic I should run 
> 
>  git push -f origin  c945bf50251150e0d4ad7ee751c7e9615cb4b3e8:master

That is correct.

> But this seemed not to have helped. 

It had - read on ;-)

> When I clone the repository

That wasn't needed; you would have been better off by merely running

  git fetch origin

which would update in your local repository the so-called "remote branches"
for the remote repo known as "origin". Remote branches are sort of bookmarks
which capture the state of the branches in a named remote repository last time
they were observed.

> I see in a different local directory again adn run 
> 
>  git log --all 
> 
> @commit 89346f81fef27286bd3fb1ed3ddc94a6f3fb560d (origin/copyright, 
> origin/copy)
[...]
> * commit 66380013003549a6851d4e110b29a5a439e05609
[...]
> * commit c945bf50251150e0d4ad7ee751c7e9615cb4b3e8 (HEAD -> master, 
> origin/master, origin/HEAD)
> 
> That is these two commits have not been removed.

They had: please pay attention to the names of the "references" taken in
parentheses - your two "extra" commits are at the tips of the branches
named origin/copyright and origin/copy, while origin/master point at the
correct commit - exactly that you have told remote Git to update its "master"
branch with.

Now please note that there are more info attached to the commit c945bf there:

 * HEAD -> master tells you that c945bf is the commit currently checked out
   (HEAD always points at the commit which you're working on).
   And the arrow tells you which local branch will be updated should you
   record a new commit.

   So this bit tells you that you have the local branch "master" checked out,
   and it has the expected commit at its tip - just what you have requested
   by executing that `git push` command above.

 * origin/HEAD is of less interest but let's describe it, too.
   The HEAD in a remote repository points at a branch which will be "the
   default" one in the repositories which are created when that remote repo
   is cloned (the books usually say it's "master" but in fact it's what HEAD
   points at).

In other words, it's the usage of the "--all" command-line option which
tripped you: should you have examined just origin/master, you'd have seen that
everything is normal.
I'll try to expand on those "origin/" prefixes in a moment.

> Not sure how to proceed.

Well, at first, note that all is in green area now.
You might want to furthr adjust things a bit, if you want, but the "master"
branch in the remote repository has the state you shought for it to be in your
initial mail.

So, let's look at those "origin/" prefixes.
As I've already said, when the user has configured in their local repository
one or more "named remote repositories" - and "origin" is one of such
reporisories; `git clone` creates it automatically, - Git starts to track the
state of the branches in these repositories. These branches are created in
what you can call "a namespace", with the namespace being the name of the
remote. So git tracks the state of the branch "master" in the remote known as
"origin" as "origin/master" in your local repository. These branches are called
"remote branches" (which is a bit unfortunate because they are maintained in a
local repository).
Each time an operation like `git push` or `git fetch` involving that remote
repo is executed, Git updates the state of one or more remote branches for
that repository (which exactly - depends on the specifics of each particular
operation, let's not dig deeper right now).

As you can see, when you have cloned your updated repository, Git created in
it a set of remote branches which follow the state of the branches in the
origin (remote) repository. Judging from the output of `git log --all`,
the remote repository has at least three branches: master, copy and copyright,
and that why `git log` decorates their tip commits in its output with the
names of the remote branches.
Basically this means that the master branch in the remote repository points at
the now-correct commit, but the branches copy and copyright - are not.

You could have verified that without cloning - merely by running

  git fetch origin

or

  git fetch --prune origin

(which is the same but would also delete those remote braches which have been
following the branches in the remote repo which have been deleted since the
last check), and then inspecting the state of origin/master.

As to what to do now - it depends on what your end goals are.

First, as I've already said, I'd recommend to first run

  git fetch --prune origin

in your local repo.

You could then reset your local branch master to that same commit c945bf.
That could be done by, say,

  git checkout master
  git reset --hard origin/master

which would make the local master to point at the same commit master in the
origin repo does.

Then you might want to get rid of either of those branches - copy and
copyright, - or both of them.

If you do not need them both in your local repo and in the remote one, just do

  git branch -D copy copyright
  git push origin :copy :copyright

(the latter means "push nothing to the „copy” branch" and the same for the
copyright branch).

Of course, you might do something else like continue to work on either of
those branches and merge them to master when they are ready or something like
this.

If you need further clarifications or guidance, ask away.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/20211127193930.miaxnqt3qo7v6iec%40carbon.

Reply via email to