![]() However - like we said earlier, some maintainers want a clean history. You can even make as many commits as you like, really. Option 3: Committing and squashingĪnother option you can do, which is a bit more standard and which you may be used to, is to edit your file, and then make a new commit. ![]() This is safer than -force, and should be used if possible. It’s very convenient: force pushes that use lease won’t overwrite the branch if other committers have added commits to the branch, since. Note: Since this post was first publishes, -force-with-lease has entered the Git core. The old comments telling you to change stuff are now in an outdated diff, the code shows the most recent version, and you’re ready to merge. Git will overwrite the remote commit with your commit, and now you’ll see that the PR has also automatically been updated on GitHub. This will tell git to not care that this is a different commit. Now comes the part you normally shouldn’t do, but since the maintainers have asked you, and since you know it is to your own branch, and since you’re not too worried about being a Sith lord: git push -f origin HEAD. When you save ( :wq again), it will register that a new commit has been logged. ![]() Change the message as you see fit you’ll see your edits are now actually part of the commit, too. amend opens up the interactive commit message environment you are used to from git commit. But don’t worry - git will warn you if you try to run git push origin HEAD at any point, as it knows that the commit has been changed, and you should know what you’re doing before pushing. This only changes things locally, which means you have to be careful about pushing elsewhere or expecting anyone else to have your changes. amend is your friend - it lets you change a commit by adding to it, editing the commit message, or even doing things like changing who made the commit and when it was committed. The git manuals aren’t really all that bad.) Then, we typed git commit -amend. (If you ever want to know what a git command flag means, type the equivalent of man git-add. You see that we added the edits to git’s staging area, with git add -A. # There's no reason you can't use your usual editor to edit the file. # Do the edits you need to, here, and then type `:wq`. Most maintainers I know would agree with me. Is it important that a maintainer told you to remove a trailing space? I don’t think so. But, more relevantly, they often aren’t that important. ![]() Technically, they are saved on GitHub in outdated diffs, if anyone wants to see them, although they won’t be in the git history itself (which makes them less accessible and useful). The only person likely to be touching that branch will be you.Ī lot of people complain that then the comments made by the maintainers will be lost. No one is going to be touching that PR, so you don’t have to worry about dirtying past history. While most git guides tell you that “Force pushing is the worst thing in the world, and it makes you a Sith Lord if you use them, and we will find you and hunt you down”, really, it makes sense in situations where a commit on a non-merged PR should be changed. If you’re using a different naming scheme for origin and upstream, you will need to update that accordingly, of course.) Option 2: Manually add changes, amend, and force push git push origin HEAD is just longhand for pushing to whatever branch you’re currently on. ![]() (On a side note: git push is enough if you’re on newer git versions and the remote matches local. A second commit removing a space, added by accident in the previous commit, isn’t really useful for anyone. Some repositories like to have a very clear history, where each commit shows something meaningful that happened. However, for things like spelling edits, line removals, or general small nitpicky things that the maintainers want you to do, having an extra commit may not be the best option. What this does is provide you with a very clear history of what was committed where, and anyone can see this in the PR and in the future history of the project if it is merged in. $ echo 'these are some edits' > your_file.md ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |