0

As I understand from answers given elsewhere on StackExchange - the process is suppossed to be simple:

a) git checkout master
b) git fetch origin
c) git pull origin
d) git push myremote # named aixtools
e) git checkout bpo-XXXXX
f) git merge master
g) git push myremote

Until step g) everything works as expected. And when it is a tag from the 'origin' rather than a 'PR' I am trying to keep in sync, the process works fine.

Help, wisdom, guidance, et al is much appreciated:

step g currently

michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git status
On branch bpo-11191
Your branch is ahead of 'aixtools/bpo-11191' by 564 commits.
  (use "git push" to publish your local commits)
nothing to commit, working tree clean
michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git push aixtools
Username for 'https://github.com':
Password for 'https://[email protected]':
To https://github.com/aixtools/cpython.git
 ! [rejected]        bpo-11191 -> bpo-11191 (non-fast-forward)
error: failed to push some refs to 'https://github.com/aixtools/cpython.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

A day further: I am thinking, after reading up more on reset and merge, and some of the examples there - that rather than a pull to my local master, commit of local master, and then merge local branch with local 'master' I should also just 'pull' from 'other remote' as a kindof merge.

In any case - I restored a backup of the local situation (always make a copy when I try some 'new' for me with git) And I hope the following answers the comment/query regarding the status of the 'local'

michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git branch
* bpo-11191
  master
michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git status
On branch bpo-11191
Your branch is up-to-date with 'aixtools/bpo-11191'.
nothing to commit, working tree clean
michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git diff aixtools/bpo-11191
michael@x071:[/data/prj/python/git0/gcc-python3-3.7]

Or

michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git log --oneline | head -1
5a3284f (HEAD -> bpo-11191, aixtools/bpo-11191) Fix test_run and related tests Almost fix test_search_cpp
michael@x071:[/data/prj/python/git0/gcc-python3-3.7] aixtools/bpo-11191 | head -1     <
5a3284f (HEAD -> bpo-11191, aixtools/bpo-11191) Fix test_run and related tests Almost fix test_search_cpp

So, maybe the question needs to be rephrased:

  • should I merge locally?
  • pull from "other remote" aka 'project owners'?
  • something else entirely?

Next attempt - using merge (maybe I should have merged from a different branch. "master" was what is now 3.7 (I am guessing) - so maybe I should have merged from cpython/3.7.

So, now I feel "howto"ish again.

Basically, I have a PR that I would like to keep/verify that it is still "in sync" with current developments - and update the PR with the current status. A (desired by me) side-effect is that the PR will be re-evaluated again by the "verification process".

I may be facing a situation that "cpython" does not merge my PR before the next release. Should that happen I would like to use, as much as possible, git "merge" and/or "pull" of my open PR (aka bpo-XXXXX) into a "AIX-release" branch.

The steps I see for that would be:

a) checkout the official release branch
b) create and checkout a new "aix-release" branch
c) merge my (local) branches, one at a time, into the new branch
d) commit (and push) the new "release"

So, to simplify/verify the merge into the new release I would like to know, and "store" the bpo-XXXXX with the most recent "sync" with the master and/or named branches.

I am aware that - when it comes to git - I am a Sunday driver. It may be obvious to you. But I think for many (at least I hope I am not alone :smile:) git is not straightforward in what does what. Very powerful - yes - but I feel overwhelmed by it's power. Thx for your assistance!

(FYI: last attempt, new failure - I am very curious about what specific steps were used to -- checkout, merge, and push - and have it all work? Did you get my bpo, push that, then merge, then commit (local), then push - or use some other workflow. Probably - what I am looking for is the workflow that came ' naturally' to you.

michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git merge cpython/master
...
Merge made by the 'recursive' strategy.
...

michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git status
On branch bpo-11191
Your branch is ahead of 'aixtools/bpo-11191' by 564 commits.
  (use "git push" to publish your local commits)
nothing to commit, working tree clean

michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git push aixtools
Username for 'https://github.com':
Password for 'https://[email protected]':
To https://github.com/aixtools/cpython.git
 ! [rejected]        bpo-11191 -> bpo-11191 (non-fast-forward)
error: failed to push some refs to 'https://github.com/aixtools/cpython.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git pull cpython
remote: Counting objects: 1908, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 1908 (delta 752), reused 751 (delta 751), pack-reused 1153
Receiving objects: 100% (1908/1908), 1.11 MiB | 2.01 MiB/s, done.
Resolving deltas: 100% (1334/1334), completed with 161 local objects.
From https://github.com/aixtools/cpython
   fea0a12..b94d739  3.7        -> cpython/3.7
You asked to pull from the remote 'cpython', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.

michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git pull cpython 3.7
From https://github.com/aixtools/cpython
 * branch            3.7        -> FETCH_HEAD
Auto-merging README.rst
CONFLICT (content): Merge conflict in README.rst
Auto-merging Python/importlib_external.h
CONFLICT (content): Merge conflict in Python/importlib_external.h
Auto-merging Python/importlib.h
CONFLICT (content): Merge conflict in Python/importlib.h
Auto-merging Python/compile.c
CONFLICT (content): Merge conflict in Python/compile.c
Auto-merging Objects/frameobject.c
CONFLICT (content): Merge conflict in Objects/frameobject.c
Auto-merging Lib/test/test_sys_settrace.py
CONFLICT (content): Merge conflict in Lib/test/test_sys_settrace.py
Auto-merging Lib/test/test_random.py
CONFLICT (content): Merge conflict in Lib/test/test_random.py
Auto-merging Lib/pydoc_data/topics.py
CONFLICT (content): Merge conflict in Lib/pydoc_data/topics.py
Auto-merging Lib/importlib/_bootstrap_external.py
CONFLICT (content): Merge conflict in Lib/importlib/_bootstrap_external.py
Auto-merging Lib/enum.py
Auto-merging Include/patchlevel.h
CONFLICT (content): Merge conflict in Include/patchlevel.h
Auto-merging Doc/whatsnew/3.7.rst
CONFLICT (content): Merge conflict in Doc/whatsnew/3.7.rst
Auto-merging Doc/tools/templates/indexsidebar.html
CONFLICT (content): Merge conflict in Doc/tools/templates/indexsidebar.html
Auto-merging Doc/tools/extensions/pyspecific.py
Auto-merging Doc/library/re.rst
CONFLICT (content): Merge conflict in Doc/library/re.rst
Auto-merging Doc/library/dis.rst
CONFLICT (content): Merge conflict in Doc/library/dis.rst
Auto-merging Doc/library/configparser.rst
CONFLICT (content): Merge conflict in Doc/library/configparser.rst
Auto-merging .travis.yml
CONFLICT (content): Merge conflict in .travis.yml
Auto-merging .github/appveyor.yml
CONFLICT (content): Merge conflict in .github/appveyor.yml
Automatic merge failed; fix conflicts and then commit the result.
5
  • That’s rather odd, how did you build your local bpo-11191 branch? I forked your repository, and ran git checkout bpo-11191; git merge master; git push and it worked fine, as you can see on github.com/skitt/cpython/tree/bpo-11191. Apr 28, 2018 at 21:18
  • The fast-forward rejection basically means you did something to rewrite history (such as a rebase). You need to force push to get it to work, but also consider the implications - if someone else already has a checkout of that branch they will not be able to pull your changes without a git reset --hard.
    – jordanm
    Apr 28, 2018 at 21:52
  • as far as I understand it, my local is what I pushed. They should be the same. However, if a checkout from the remote, and then a merge plus push solves it - I am happy. I'll reply again later. I have a copy of the local situation - if my local is not the same as my remote there should be a git diff command I can run to see the difference. I thought I check that already - before the question. I'll rinse and repeat. Not the first time I have not understood the magic of git. :) In any case - thx for the hope! (p.s. not done a rebase - that I can recall. 3 months ago that I did anything on this.) Apr 28, 2018 at 22:07
  • @StephenKitt - yes I see 564 commits ahead - same status I get locally, but I cannot push my local. Do you have a better idea? And, git merge master - which master (aixtools - that I had updated, or from cpython? - Do you perhaps have a git-config setting that you try to ff merges whenever possible - while mine seem to be using "recursive" strategy? Apr 29, 2018 at 12:12
  • so, left to my own devices it seems. :) Apr 30, 2018 at 18:32

2 Answers 2

0

You might want to try git pull -r. This (tries to) add remote changes "below" your local changes, then you can git push the result back.

0

As an answer - as I have something working for me.

First of all - I seem to have been following the wrong process.

The process I use now is: - startup -

  1. fork from somewhere
  2. clone my fork "as origin"
  3. add "somewhere" as remote_origin

This directory I call "master", e.g., cpython-master for my cpython fork

The 'only' activity I do with this directory is "fetch and/or pull" from the remote_origin and then push to "origin".

This was working before - but I was getting lost when I had made a branch (that was submitted as a PR but not (yet) merged into remote_origin) and wanted to update that PR to include the latest updates.

So, what works now?

  1. start with a new clone "of my fork!"
  2. switch to the tagged branch that I consider 'latest'
  3. pull/fetch my previous branch into new branch
  4. get everything working - maybe needing to rinse and repeat back to this step
  5. choose a branch name (maybe same as old one, maybe new)
  6. commit locally
  7. push to github

What made a difference for me is not trying to merge the updates from either origin into my 'existing' branch but instead go to the 'new' remote_origins tag on a clone from my fork, and then "pull" my pull request into that situation.

While I am not absolutely clear on why this works better - at least I do not see:

hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
3
  • @muru - personally, I prefer the steps "tighter" together, which is why I was not using the automated "1. 2. 3., etc.. C'est la vie. May 13, 2018 at 15:55
  • Maybe, but that's not what code formatting is for and neither are any of the other features of code formatting needed here otherwise. Presenting simple text as a code block doesn't help readability or accessibility. If you want lines close together, I'd suggest using Stylish and some custom CSS. For example, compare: i.stack.imgur.com/0sBl9.png and i.stack.imgur.com/ovkZi.png
    – muru
    May 13, 2018 at 16:03
  • I’ll never remember how to do that. If I have to spend more time trying to get it formatted “properly” than I do working on the Q or A - guess I will contribute less rather than more. So just my thanks for your making it proper. :) May 13, 2018 at 16:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .