在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:nvie/git-toolbelt开源软件地址:https://github.com/nvie/git-toolbelt开源编程语言:Shell 100.0%开源软件介绍:Installation instructions
git-toolsHelper tools to make everyday life with Git much easier. Commands marked with
Everyday helpful commands:
Statistics: Commands to help novices out: Commands that simplify scripting. These commands typically only return exit codes and have no output.
Advanced usage:
git current-branchReturns the name of the current branch, if any. Why doesn't this come with git? $ git current-branch
master Alias to git main-branchReturns the name of the default main branch for this repository. Historically
$ git main-branch
master git shaReturns the SHA value for the specified object, or the current branch head, if nothing is provided. $ git sha <some-object> Typical example: $ git sha HEAD
f688d7543c5d52f5f78b3db1b0dd1616059299a4
$ git sha -s HEAD
f688d75 Shows the commit SHA for the latest commit. git modifiedReturns a list of locally modified files. In contrast to git status, it does not include any detailed file status, and never includes non-existing files. This makes it ideal for the following use-case: $ vim (git modified) If you want to locally modified files that are already staged, too, use: $ vim (git modified -i) git modified-sinceLike git-modified, but for printing a list of files that have been modified since master (or whatever commit specified). In contrast to git status, it does not include any detailed file status, and never includes non-existing files. Opens all files modified on your branch (since you branched off $ vim (git modified-since) git separatorAdds a commit with a message of only ---'s, so that it visually separates commits in the history. This is incredibly useful when doing more complex rebase operations. (They should be used as a temporary measure, and ideally taken out of the history again when done rebasing.) git spinoffInspired by Magit's This is useful to create a feature branch after work has already began on the old branch (likely but not necessarily "master"). git push-currentPushed the current branch out to Accepts options, too, so you can use $ git push-current -f to force-push. git is-headlessTests if git diff-sinceShows the differences made on the current branch, compared to the main branch (or the given branch). git local-branches / git remote-branches / git active-branchesReturns a list of local or remote branches, but contrary to Git's default commands for this, returns them machine-processable. In the case of remote branches, can be asked to return only the branches in a specific remote. For git local-branch-exists / git remote-branch-exists / git tag-existsTests if the given local branch, remote branch, or tag exists. git recent-branchesReturns a list of local branches, ordered by recency:
git remote-tracking-branchPrint the name of the remote tracking branch of the current or given local branch name, if one exists. Errors otherwise. git local-commits / git has-local-commitsReturns a list of commits that are still in your local repo, but haven't been
pushed to git contains / git is-ancestorTests if X is merged into Y:
CAVEAT:
Even though they might look like opposites, git stage-allMimics the index / staging area to match the working tree exactly. Adds files, removes files, etc. Alias to git unstage-allUnstages everything. Leaves the working tree intact. Alias to git undo-mergeEver created a merge accidentally, or decided that you didn't want to merge
after all? You can undo the last merge using git undo-commitEver committed too soon, or by accident? Or on the wrong branch? You can now undo your last commit and you won't lose any data. All the changes in the commit will be staged (like right before the commit) and the commit itself is gone. git cleanupDeletes all branches that have already been merged into the main branch. Keeps other branches lying around. Removes branches both locally and in the origin remote. Will be most conservative with deletions. git fixupAmend all local staged changes into the last commit. Ideal for fixing typo's, when you don't want to re-edit the commit message.
git fixup-withInteractively lets you pick a commit to fixup with. (Uses git workonConvenience command for quickly switching to a branch git delouseSay you want to rebuild your last commit, but want to keep the commit message. git delouse empties the last commit on the current branch and places all changes back into the working tree. Since the commit remains in history, you can now rebuild the commit by "git amend"'ing or "git fixup"'ing, instead of making new commits. git shatter-by-fileSplits the last commit into N+1 commits, where N is the number of files in the last commit. The first commit is an empty commit with the original commit message and author details, and the following commits add (or delete) one file each, keeping the subject line of the original commit message. After running git cleaveSplits the last commit into 2 or more commits. Takes one or more regex values
(which are fed to For example:
Will split the last commit into 2 (or 3) commits. The first one will contain
all the files containing Another example:
This will split off all Javascript files from a commit. git commit-toEver been on a branch and really wanted to quickly commit a change to a different branch? Given that this is possible without merge conflicts, git commit-to will allow you to do so, without checking out the branch necessarily.
git cherry-pick-toEvery been on a branch, just made a commit, but really want that commit available on other branches as well? You can now cherry-pick this commit to any branch, staying on the current branch. (Given the change won't lead to a merge conflict.)
git is-repoHelper function that determines whether the current directory has a Git repo
associated to it. Scriptable equivalent of git root / git repo
git initial-commit
git has-local-changes / git is-clean / git is-dirtyHelper function that determines whether there are local changes in the working tree, by returning a 0 (local changes) or 1 (no local changes) exit code. git drop-local-changesDon't care about your local working copy's state and really want to revert back to whatever is recorded in the history? git drop-local-changes lets you do this. This covers aborting rebases, undoing partial merges, resetting the index and removing any unknown local files from the work tree. Anything that is already committed remains safe. ??? issue a git pull, too? Typical beginners will want this. git stash-everythingThe stash behaviour you (probably) always wanted. This actually stashes everything what's in your index, in your working tree, and even stashes away your untracked files, leaving a totally clean working tree. Using "git stash pop" will recover all changes, including index state, locally modified files, and untracked files. git update-allUpdates all local branch heads to the remote's equivalent. This is the same as checking out all local branches one-by-one and pulling the latest upstream changes. Will only update if a pull succeeds cleanly (i.e. is a fast-forward pull). git-merged / git-unmerged / git-merge-statusThis trio of subcommands makes it easy to inspect merge status of local branches. Use them to check whether any local branches have or haven't been merged into the target branch (defaults to master). git-merge-status is a useful command that presents both lists in a single overview (not for machine processing). git-branches-containingThis command, "git branches-containing []" returns a list of branches which contain the specified '' (defaults to 'HEAD'). git-branches-containing is useful to see if a branch has been merged, and, if so, which releases contain the feature/fix (if you use release branches). git-committer-infoShows contribution stats for the given committer, like "most productive day", "most productive hour", "average commit size", etc. TODO: git force-checkoutDon't care about your local working copy's state and really want to switch to another branch? git force-checkout lets you do this. Switching branches can be prevented by git. For good reasons, mostly. Git is designed to prevent you from losing data potentially. Examples are there are local unmerged files, or some files that would be overwritten by doing the checkout. By using force-checkout you basically give git the finger, and check out a branch anyway. You do agree to lose data when using this command.
git conflictsGenerates a summary for all local branches that will merge uncleanly—i.e. will lead to merge conflicts later on.
git-skip / git-unskip / git-show-skippedGit supports marking files "skip worktree", meaning any change in the file locally will not be shown in status reports, or be added when you stage all files. This feature can be useful to toggle some switches locally, or experiment with different settings, without running the risk of accidentally committing this local data (that should remain untouched in the repo). Notice that status reports won't show these files anymore, so it's also easily to lose track of these marked assumptions, and you probably run into weird issues if you don't remember this. (This is the reason why I put these scripts in the "advanced" category.) Basic usage:
As you can see, git wipCommits all local changes under a commit message of "WIP". Great for quickly
creating "savepoint" commits. If there is a mix of staged changes, and
unstaged changes, and new files, will commit each of these as a separate
commit, all titled "WIP". Effectively, running |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论