<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">Personally, I try to make sure that
regular-merges are the norm, and rebase/reset is the exceptional
case. Once you use rebase, you typically need to use force-push,
and once you start using force-push regularly, it is easy to lose
commits because you force push and actually lose something on the
remote that you didn't incorporate into the local push-source.<br>
<br>
If you never commit to your local master (or origin/master), it
will never diverge from upstream/master, and the reset/push
--force will not be necessary.</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">I don't think you comments match what
is being done:<br>
<br>
git checkout master # switch to local branch master</div>
<div class="moz-cite-prefix">git pull upstream master # fetch
upstream master and merge upstream/master into current branch</div>
<div class="moz-cite-prefix"># does not: overwrite my local master
with remote upstream/master<br>
</div>
<div class="moz-cite-prefix">git reset --hard upstream/master # move
local branch to point to upstream/master</div>
<div class="moz-cite-prefix">git push origin master --force # push
master branch back to fork's master</div>
<div class="moz-cite-prefix">portindex</div>
<div class="moz-cite-prefix"><br>
These instructions would be (kind of) correct if you think the
origin/master branch or local master branch might diverge from
upstream/master. However, even then, you have a pull (which
merges), then a reset (which discards). That is, either:</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">git checkout master ; git pull upstream
master ; git push</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">or:</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">git checkout master ; git fetch
upstream ; git reset --hard upstream/master ; git push --force
origin master</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">The reset/force-push is a bit
contradictory: the instructions indicate that something might have
been added to the master branch, but it is being discarded. Why
would something be added to the master branch if it should not be
retained. Also, why pull (merge) if the next step is going to
reset --hard. If the branches have diverged, you might have a
merge conflict.<br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">The "git push --force" would close an
open PR if the PR's branch was your master branch (since
origin/master and upstream/master are the same, the PR would be
closed). Otherwise, I don't see how pushing to master would
affect PRs on non-master branches.</div>
<div class="moz-cite-prefix"><br>
My approach:<br>
<br>
a) Never commit to your fork's master (besides pull from upstream)<br>
</div>
<div class="moz-cite-prefix">b) Always push your changes to fork's
branch(es)<br>
c) PRs from fork branch</div>
<div class="moz-cite-prefix"><br>
A periodic "git checkout master && git pull upstream
master && git push" should keep fork's master branch
up-to-date.<br>
<br>
As to whether you local git repo is ok:<br>
<br>
- Check "git status" does not show anything modified (or not
checked in)<br>
- Once you see everything is checked in, "git diff
upstream/master" will show diffs between local commit</div>
<div class="moz-cite-prefix">- "git rev-parse HEAD upstream/master"
will show the SHAs of you local branch and upstream/master. It
seems like you want them to be the same.<br>
</div>
<div class="moz-cite-prefix"><br>
-Justin<br>
</div>
<br>
<div class="moz-cite-prefix">On 2/19/22 07:59, Gerben Wierda via
macports-users wrote:<br>
</div>
<blockquote type="cite"
cite="mid:F95DC47A-AA2E-4FE3-9B49-329A6E5CAE8D@rna.nl">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
I have my own fork&clone of macports-ports in case I want to
do maintenance. Getting a clean local clone for me means:
<div class=""><br class="">
</div>
<div class="">
<div class=""><span style="font-style: normal; font-size: 11px;"
class=""><font class="" face="Menlo"># First, do an update
of macports base only (does not update the ports tree):</font></span></div>
<div class=""><span style="font-style: normal; font-size: 11px;"
class=""><font class="" face="Menlo"><br class="">
</font></span></div>
<div class=""><span style="font-style: normal; font-size: 11px;"
class=""><font class="" face="Menlo">sudo port selfupdate
--no-sync</font></span></div>
<div class=""><span style="font-style: normal; font-size: 11px;"
class=""><font class="" face="Menlo"><br class="">
</font></span></div>
<div class=""><span style="font-style: normal; font-size: 11px;"
class=""><font class="" face="Menlo"># Updating the master
of my fork&clone from the master of the original:</font></span></div>
<div class=""><span style="font-style: normal; font-size: 11px;"
class=""><font class="" face="Menlo"><br class="">
</font></span></div>
<div class=""><span style="font-style: normal; font-size: 11px;"
class=""><font class="" face="Menlo">git checkout master<span class="Apple-tab-span" style="white-space:pre"> </span>#
Go to branch master in my local clone</font></span></div>
<div class=""><span style="font-style: normal; font-size: 11px;"
class=""><font class="" face="Menlo">git pull upstream
master<span class="Apple-tab-span" style="white-space:pre"> </span>#
Update my local clone master from the master of the remote
upstream</font></span></div>
<div class=""><span style="font-style: normal; font-size: 11px;"
class=""><font class="" face="Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>#
(overwrites my local master with remote
github/macports/master)</font></span></div>
<div class=""><span style="font-style: normal; font-size: 11px;"
class=""><font class="" face="Menlo">git reset --hard
upstream/master<span class="Apple-tab-span" style="white-space:pre"> </span>#
Resets index and working tree of local clone/master from
remote upstream</font></span></div>
<div class=""><span style="font-style: normal; font-size: 11px;"
class=""><font class="" face="Menlo">git push origin master
--force <span class="Apple-tab-span" style="white-space:pre"> </span>#
Push local clone (~/MacPortsDev/macports-ports) master
back</font></span></div>
<div class=""><span style="font-style: normal; font-size: 11px;"
class=""><font class="" face="Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>#
to my own remote fork (github/gctwnl/macports-ports)</font></span></div>
<div class=""><span style="font-style: normal; font-size: 11px;"
class=""><font class="" face="Menlo"><span class="Apple-tab-span" style="white-space:pre"> </span>#
NOTE: this closes all open pull-requests!</font></span></div>
<div class=""><span style="font-family: Menlo; font-size: 11px;"
class="">portindex</span><span class="Apple-tab-span" style="font-family: Menlo; font-size: 11px; white-space: pre;"> </span><span
style="font-family: Menlo; font-size: 11px;" class=""># Tell
macports to use this tree and update the macports index</span></div>
</div>
<div class=""><br class="">
</div>
<div class="">Apparently, in the past UI have accidentally done
some of this as root, so this failed because parts of the
macports-ports clone were owned by root.</div>
<div class=""><br class="">
</div>
<div class="">So, I did a chown -R on that tree and tried again,
but now I get</div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">albus:macports-ports
sysbh$ git pull upstream master</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">From
<a href="https://github.com/macports/macports-ports"
class="moz-txt-link-freetext" moz-do-not-send="true">https://github.com/macports/macports-ports</a></span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class=""> *
branch master -> FETCH_HEAD</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">Updating
e0a3df02c73..eca5c1226ee</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class="">error:
Your local changes to the following files would be
overwritten by merge:</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>_resources/port1.0/checks/implicit_function_declaration/macosx10.10.sdk.list</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px;
line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>_resources/port1.0/checks/implicit_function_declaration/macosx10.11.sdk.list</span></div>
</div>
<div class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">…</span></div>
<div class=""><span style="font-variant-ligatures:
no-common-ligatures" class="">
<div style="margin: 0px; font-stretch: normal; font-size:
11px; line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures"
class="">error: The following untracked working tree files
would be overwritten by merge:</span></div>
<div style="margin: 0px; font-stretch: normal; font-size:
11px; line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures"
class=""><span class="Apple-tab-span" style="white-space:pre"> </span>aqua/qt5/files/patch-qtwebengine_gn_binary_path.diff</span></div>
<div style="margin: 0px; font-stretch: normal; font-size:
11px; line-height: normal; font-family: Menlo;" class=""><span
style="font-variant-ligatures: no-common-ligatures"
class=""><span class="Apple-tab-span" style="white-space:pre"> </span>comms/s710/files/dynamic_lookup-11.patch</span></div>
<div class=""><span style="font-variant-ligatures:
no-common-ligatures" class=""><br class="">
</span></div>
</span></div>
<div class="">So I tried to do </div>
<div class=""><br class="">
</div>
<div class=""><span style="font-family: Menlo; font-size: 11px;"
class="">git reset --hard upstream/master</span></div>
<div class=""><br class="">
</div>
<div class="">and apparently this did work as another pull did
nothing. But before I push that back to my own clone: have I
done anything wrong? Is my local tree in order now?</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color:
rgb(0, 0, 0); letter-spacing: normal; text-align: start;
text-indent: 0px; text-transform: none; white-space: normal;
word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none; word-wrap: break-word;
-webkit-nbsp-mode: space; line-break: after-white-space;"
class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color:
rgb(0, 0, 0); letter-spacing: normal; text-align: start;
text-indent: 0px; text-transform: none; white-space:
normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none; word-wrap: break-word;
-webkit-nbsp-mode: space; line-break: after-white-space;"
class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color:
rgb(0, 0, 0); letter-spacing: normal; text-align: start;
text-indent: 0px; text-transform: none; white-space:
normal; word-spacing: 0px; -webkit-text-stroke-width:
0px; text-decoration: none; word-wrap: break-word;
-webkit-nbsp-mode: space; line-break:
after-white-space;" class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color:
rgb(0, 0, 0); letter-spacing: normal; text-align:
start; text-indent: 0px; text-transform: none;
white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;
word-wrap: break-word; -webkit-nbsp-mode: space;
line-break: after-white-space;" class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0);
color: rgb(0, 0, 0); letter-spacing: normal;
text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration:
none; word-wrap: break-word; -webkit-nbsp-mode:
space; line-break: after-white-space;" class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0);
color: rgb(0, 0, 0); letter-spacing: normal;
text-align: start; text-indent: 0px;
text-transform: none; white-space: normal;
word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none; word-wrap: break-word;
-webkit-nbsp-mode: space; line-break:
after-white-space;" class="">
<div dir="auto" style="caret-color: rgb(0, 0, 0);
color: rgb(0, 0, 0); letter-spacing: normal;
text-align: start; text-indent: 0px;
text-transform: none; white-space: normal;
word-spacing: 0px; -webkit-text-stroke-width:
0px; text-decoration: none; word-wrap:
break-word; -webkit-nbsp-mode: space;
line-break: after-white-space;" class="">
<div>
<div class="">Gerben Wierda (<a
href="https://www.linkedin.com/in/gerbenwierda"
class="" moz-do-not-send="true">LinkedIn</a>)</div>
<div class=""><a href="https://ea.rna.nl/"
class="" moz-do-not-send="true">R&A IT
Strategy</a> (main site)<br class="">
Book: <a href="https://ea.rna.nl/the-book/"
class="" moz-do-not-send="true">Chess and
the Art of Enterprise Architecture</a><br
class="">
Book: <a
href="https://ea.rna.nl/the-book-edition-iii/"
class="" moz-do-not-send="true">Mastering
ArchiMate</a><br class="">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br class="">
</div>
</blockquote>
<p><br>
</p>
</body>
</html>