0

In my README.md I have a link to a GitHub issue:

Fix world
__ Fix: https://github.com/eth-brownie/brownie/issues/1174

I am continually rewriting (and then force pushing) a commit to GitHub. (message contains the last commit's message which contains the GitHub issue link):

message=$(git log -1 --pretty=%B | awk 'NF{$1=$1};!NF||!seen[$0]++')
git commit --amend --quiet --no-verify -m "$message"
git push -f

After doing this operation many times, in the GitHub issue link I see the following: enter image description here

Overall I observe that each commit into my last commit had a footprint into the GitHub issue URL. Would it be possible to prevent this?

Basically after doing adding more changes to the last commit, I want to clean its previous linked footprints on GitHub issues, and only keep a single reference related to my latest commit.


What's the reason to rewrite a commit so many times?

I doing my work in a development branch.

By habbit I keep doing this operation when I make a single change on the branch I am working on. When I switched into another node, I do git pull --rebase (this triggers itself automatically on the background) and I continue on working on the branch and if I make change I do the commit again into the latest commit.

I just wanted to keep my git history clean for other nodes.

8
  • Presumably you have pushed all of those commits with messages referencing the issue, though? This is what happens when you rewrite public history; most of those commits are now unreachable ("This commit does not belong to any branch on this repository..."), but they do all refer to the issue. It's unclear why you've needed to keep rewriting the same commit over and over again, but it looks like there's a lot in it - maybe you should make more smaller commits, rather than constantly rewriting a large one? Or don't push until it's finished.
    – jonrsharpe
    Commented Aug 18, 2021 at 7:53
  • @jonrsharpe you have pushed all of those commits with messages referencing the issue Yes sir, commit message remains unchange which contains the URL to the issue. I was keep pushing them into my dev branch which will be pull from other nodes if there will be any change. I was assuming since I am overwriting into my latest commit I thought that there will be single commit that contains all the changes I made. I just wanted to keep my commit history clean , I am not sure this way is a proper way to do it.
    – alper
    Commented Aug 18, 2021 at 10:22
  • There's only a single commit in the branch, but you've pushed a bunch of others that still exist within GitHub. A better way to keep a clean history would be to think about splitting the work up into smaller units, git becomes a lot less useful when everything you're doing is bundled into one massive change.
    – jonrsharpe
    Commented Aug 18, 2021 at 10:24
  • @jonrsharpe Ah I thought the prevously pushed commits will merge with the latest one I was pushing. Probably I am doing this operation every hour to save changes. I should work on to splitting the work up into smaller units, thanks for the advice. Should I delete this question since it has duplicated version?
    – alper
    Commented Aug 18, 2021 at 10:37
  • 2
    may I suggest: not doing that (:. It is not normal to rewrite history on a public branch; creating a PR, never amending commits added to that PR branch, and then squash-merging the PR (when you are satisfied the PR is complete) is one example of a standard workflow with the same result. I recommend looking for info on how software is released, gitflow is one commonly-cited example.
    – AD7six
    Commented Aug 18, 2021 at 11:00

0

Browse other questions tagged or ask your own question.