Git简短命令,用于签出,拉取,修剪和删除 [英] Git short command for checking out, pulling, prune fetching and deleting
问题描述
是否存在以下快捷方式:
Is there a shortcut for:
- 签出主人
- 从主人那里拉起
- 修剪获取(检查删除了哪些远程分支)
- 删除这些本地分支机构
场景:假设我在master上,并且在分支 foo
上签出,我进行了一些提交,并将 foo
发布到远程并也推送到了它.接下来,我将该分支合并到GitHub上的 master
并删除 foo
的在线版本,因为它已完成.现在,在离线环境中,我必须执行以下操作:
Scenario:
Let's say I'm on master and I checkout on the branch foo
, I do some commits and publish foo
to remote and push to it as well. Next I merge that branch to master
on GitHub and delete the online version of foo
since it's complete. Now in the offline environment, I have to do the following:
$ git checkout master
$ git pull
$ git fetch -p
$ git branch -d foo
或速记:
git checkout master && git pull && git fetch -p && git branch -D foo
有没有我可以执行的命令来使它变得更短?喜欢
Is there a command I can execute to make this much shorter? Like
$ git complete foo
或类似的话..?
推荐答案
别名
可用于解决此问题.
可以通过运行以下别名来创建别名:
An alias can be created by running:
$ alias cpfb="git checkout master && git pull && git fetch -p && git branch -D"
现在,您可以执行
$ cpfb foo
将执行别名中指定的那些命令.
which will execute those commands specified in the alias.
通过终端设置别名仅适用于该特定终端实例.
Setting alias through terminal lasts for only that particular terminal instance.
因此,请将它们保存在〜/.bashrc中,以使别名永久化.
Hence, save them in ~/.bashrc to make the alias permanent.
这篇关于Git简短命令,用于签出,拉取,修剪和删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!