发布于 2026-01-06 0 阅读
0

让我顺利度过周五的 Git 别名 让我顺利度过周五的 Git 别名

让我顺利度过周五的 Git 别名

让我顺利度过周五的 Git 别名

让我顺利度过周五的 Git 别名

替代文字

自从几年前从 SVN 切换到 Git 之后,我创建了一些别名,它们帮助我简化了工作流程,提高了整体效率。毕竟,快捷方式的意义就在于让生活更轻松,对吧?我想把我的别名分享给大家,尽管它们可能没什么实际用处。

分枝

co = checkout # Shortcut for checkout.
nb = checkout -b # Create a new branch and check it out.
bl = branch -l # List all local branches.
br = branch -r # List all remote branches.
blr = branch -a # Show local and remote branches.
bd = branch -d # Politely ask Git to delete a local branch.
bdf = branch -D # Sternly ask Git to delete a local branch.
Enter fullscreen mode Exit fullscreen mode

获取/同步/合并

fp = fetch -p # Fetch and prune.
sync = !git pull && git push # Pull then push current branch.
mm = !git fetch -p && git merge origin/master #Merge remote master into the current branch.
Enter fullscreen mode Exit fullscreen mode

提交

cm = commit # Shortcut for commit.
cma = commit -a # Commit all tracked.
cmam = commit -a -m # Commit all tracked with message to follow.
runAway = reset --hard # For when you just want it all to go away.
forgetAbout = rm --cached # Make Git forget about a tracked file.
Enter fullscreen mode Exit fullscreen mode

公用事业

alias = config --get-regexp ^alias\\. # List all aliases.
ec = config --global -e # Open .gitconfig in your default editor.
Enter fullscreen mode Exit fullscreen mode

如果您愿意,我已将所有这些内容(甚至可能更多)整理到一个方便的GitHub 仓库[include]中,供您在 Git 配置中使用。

我希望这些别名对你和我一样有用。

如果你有自己喜欢的别名,请在下方评论区留言。

文章来源:https://dev.to/megamattmiller/the-git-aliases-that-get-me-to-friday-1cmj