Hongmu Notes

🌿 Git command generator

Select an operation and fill in the parameters to get directly executable Git commands: commit, branch, merge, rebase, reset, remote, push and pull, staging, tag, log and clone, a total of twelve categories.
100% Browser local processing 0 Data upload

🌿 Command assembly

💡 Instructions for use

  • The branch name and remote name must be written correctly. Misspelled commands often do not report an error but take effect on other branches.
  • Commands involving reset, force push, and rebase will rewrite history. Please confirm the branch and target before execution.
  • Check Bind Upstream when pushing a new branch for the first time. You can omit the remote and branch names for subsequent pushes and pulls.
  • The command is output in a single line, making it easy to paste directly into the terminal; it is recommended to save the steps that need to be repeated into a script.

🌿 The three most commonly used operations

Daily use focuses on three categories: recording changes (submit, temporary save, store), parallelizing branches (create, switch, merge, rebase), and synchronizing with remote (push, pull, bind upstream). These three categories cover the vast majority of workflows, and the remaining commands are mostly for troubleshooting problems, such as viewing history, retrieving lost submissions, and comparing the differences between two versions. First identify which category it belongs to, and then select the corresponding command to minimize the scope of changes.

First distinguish whether it belongs to recording, branching or synchronization, and then select the corresponding command.

↕ Push and pull directions

Push is to send local submissions to the remote, and pull is to get remote submissions back to the local. The parameters of both are written in the same way: write the remote name first, then the branch name. It is recommended to bind the upstream when pushing a new branch for the first time. Afterwards, the parameters can be omitted for pushing and pulling of the branch with the same name. Select automatic rebase when pulling, so that local commits that have not yet been forked can be directly stacked on top of the latest commit, making the history easier to read; if you want to strictly not allow forks, select only allow fast forwarding.

When pushing a new branch for the first time, it must be bound to the upstream. After that, the remote and branch names can be omitted.

⚠ Three commands that will lose changes

If you choose to modify the workspace at the same time when resetting to a certain version, uncommitted changes will be discarded directly; force push will overwrite other people's submissions on the remote; rebasing a pushed branch will make the history of collaborators inconsistent. For these three operations, you need to confirm the branch name and target again after generating the command. Especially if the reset target is written incorrectly, it will be difficult to recover the lost changes. A safe alternative is to store the changes in stash and verify that they are correct before executing.

Before resetting, pushing, or rebasing a pushed branch, confirm the branch and target.

🧯 Remedies after errors

If you make a wrong commit, you can modify the latest commit and add in the missing files; if you point to the wrong branch, you can use reset to move the pointer back to the previous commit; if you delete a branch by mistake, you can rebuild it as long as you remember the commit number; if there is a conflict in the middle of a merge or rebase, continue after resolving it, or give up if you don't want to continue, and the command will take you back to the state before the operation. Mastering these remedial commands will help you avoid panic when encountering problems and reduce the risk of accidentally deleting code.

The first step in remediation is usually to find the correct commit number and get the pointer back there.

🔗 All keywords and tutorials

Keywords page of the tool12a

Return to tool home page

❓ FAQ

Do you need to pull it before submitting??
It is recommended to pull first and then submit to reduce the probability of being rejected when pushing; if there is already a submission locally, pulling it by rebasing can keep the history straight.
How to correct the wrong branch??
You can change the name using Rename, which will not affect the submission history; if you just cut the wrong branch, just switch to it and start again.
Why is the push rejected??
Most of them are remote and have commits that you don't have locally. Pull, merge or rebase first, and then push; force pushing will overwrite other people's submissions, so be careful.
Will uncommitted changes be lost??
Cut branches are generally retained, but will be discarded by resetting to an older version or conflicting abandonment operations. It is safer to submit or store it before taking action.
Which one should I choose between merging and rebasing??
If you want to keep branch and fork records, choose merge; if you want to get a straight line history, choose rebase. Do not rebase the pushed branch.
What is the difference between tags and branches?
The branch will move with new commits, and the label will be fixed on a certain commit; it is more appropriate to use labels with descriptions for release versions.