在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:xreader/git-for-humans开源软件地址:https://github.com/xreader/git-for-humans开源编程语言:JavaScript 100.0%开源软件介绍:Git for humansMotivation?Git is a mighty tool. Some time if things go wrong the syntax can be weird for newbies. The aim of this project to provide a wrapper for git to do it more readable Based on git flight rules Installation
List of commands
Find commandExample
output:
Detailed help for command
See underlying command(s)to see what command will be executed use example hgit delete submodule --describe --mysubmodule my_submodule_name output
How to add new commandsYou can add new commands in config file Example for a new command {
"command": "delete submodule",
"description": "Remove a submodule",
"mappedCommand": [
{ "command": "git","arguments": "submodule deinit {{{submodule}}}"},
{ "command": "git","arguments": "rm {{{submodule}}}"},
{ "command": "git","arguments": "rm --cached {{{submodule}}}"},
{ "command": "git","arguments": "-rf .git/modules/{{{submodule}}}"}
],
"options": [{
"name": "submodule",
"settings": {
"describe": "Submodule name",
"required": true
}
}]
} where
Commands
Change wrong name and email in last commit
What did I just commit?
Delete or remove last commit
Remove a file from the previous commit. This is particularly useful when you have an open patch and you have committed an unnecessary file, and need to force push to update the patch on a remote.
In order to remove changes for a file from the previous commit The commit message is keeped unchanged.
Reset Git to the state it was in before you made your last commit (while keeping your staged changes).
it will irreversibly change your history, and mess up the history of anyone else who had already pulled from the repository. In short, if you're not sure, you should never do this, ever. Do an interactive rebase instead and remove the line(s) corresponding to commit(s) you want to see removed
Remove last commit. If you need to delete pushed commits, you can use the following. However, it will irreversibly change your history, and mess up the history of anyone else who had already pulled from the repository. In short, if you're not sure, you should never do this, ever.
push my amended commit to a remote that was rejected with an error message. In general, avoid force pushing. It is best to create and push a new commit rather than force-pushing the amended commit as it will cause conflicts in the source history for any other developer who has interacted with the branch in question or any child branches.
if you accidentally did a hard reset, and want the changes back.
add staged changes to the previous commit.
Reset added files.
Reset added file.
Stage unstaged edits, and unstage edits staged edits.
Move unstaged edits to a new branch.
Move my unstaged edits to a different, existing branch.
Discard my local uncommitted changes (staged and unstaged).
Unstage all files you might have staged with git add.
Revert all local uncommitted changes (should be executed in repo root).
Revert uncommitted changes to a particular file or directory.
Another way to revert all uncommitted changes (longer to type, but works from any subdirectory).
Remove all local untracked files, so only files tracked by Git remain.
Get rid of some, but not all changes in your working copy (interactively). Checkout undesired changes, keep good changes. Answer y to all of the snippets you want to drop
Another strategy to discard specific changes involves using stash. Stash all the good changes, reset working copy, and reapply good changes
When you want to get rid of one specific file in your working copy.
Create a branch from a commit.
Simply reset your branch back to the desired commit pulled from/into the wrong branch. Use 'git reflog' first to see where your HEAD pointed before the bad pull
Discard local commits so my branch is the same as one on the server
Move wrongly committed changes to a
new branch.
First find out what the SHA1 of
commit hash you want to set your
master branch with
Delete local branches that were deleted upstream (remote).
Delete a remote branch
Delete a local branch that has not been merged to the current branch or an upstream
Rename the current (local) branch
Rename a different (local) branch
Create a new remote branch from current local one
Set a remote branch as the upstream for a local branch
By checking your remote branches, branch you can see which remote branch your HEAD is tracking. In some cases, this is not the desired branch.
Change origin/HEAD to track origin/master branch
You may have merged or rebased your current branch with a wrong branch, or you can't figure it out or finish the rebase/merge process. Git saves the original HEAD pointer in a variable called ORIG_HEAD before doing dangerous operations, so it is simple to recover your branch at the state before the rebase/merge
You may have merged or rebased your current branch with a wrong branch, or you can't figure it out or finish the rebase/merge process. Git saves the original HEAD pointer in a variable called ORIG_HEAD before doing dangerous operations, so it is simple to recover your branch at the state before the rebase/merge
Unfortunately, you have to force push, if you want those changes to be reflected on the remote branch. This is because you have changed the history. The remote branch won't accept changes unless you force push. This is one of the main reasons many people use a merge workflow, instead of a rebasing workflow - large teams can get into trouble with developers force pushing. Use this with caution. A safer way to use rebase is not to reflect your changes on the remote branch at all, and instead to do the following
Let's suppose you are working in a branch that is/will become a pull-request against master. In the simplest case when all you want to do is to combine all commits into a single one and you don't care about commit timestamps, you can reset and recommit. Make sure the master branch is up to date and all your changes committed
Combine commits with more control, and also to preserve timestamps, you need to do something called an interactive rebase
If you aren't working against
another branch you'll have to rebase
relative to your HEAD. If you want
to squash the last 2 commits, for
example, you'll have to rebase
against HEAD
Performs the merge but pretends the merge failed and does not autocommit, giving the user a chance to inspect and further tweak the merge result before committing. no-ff maintains evidence that a feature branch once existed, keeping project history consistent
Merge a branch into a single commit
Combine only unpushed commits. Interactive rebase that lists only the commits that you haven't already pushed, so it will be safe to reorder/fix/squash anything in the list
Sometimes the merge can produce problems in certain files, in those cases we can use the option abort to abort the current conflict resolution process, and try to reconstruct the pre-merge state.
To check if all commits on a branch are merged into another branch, you should diff between the heads (or any commits) of those branche.
This will tell you if any commits are in one but not the other, and will give you a list of any nonshared between the branches. (Another option is to do this see "check commits merged").
If the merges are complicated, you can use a visual diff editor
To stash only one file from your working directory
stash with message
Remove a submodule
Restore deleted not commited file
Restore a deleted file from previous commit. Finds the commit when the file last existed then checkouts that file
Remove a file from Git but keep the file
Add an empty directory to my repository
Cache a username and password for a repository
Cache a username and password for a repository with timeout Options:
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论