我在运行Windows 7的笔记本电脑上使用最新的Git bash for Windows.当我定义我的别名时:
$ alias gitc='git commit -a'
Run Code Online (Sandbox Code Playgroud)
在会议期间一切运作良好,但如果我关闭并打开bash,我无法恢复它们.但是,保留了命令历史记录.
我该怎么办?我错过了什么?
谢谢!
cto*_*tor 72
在命令中打开git bash类型时touch .bash_profile
.遵循这种类型vim .bash_profile
.然后,您可以将别名添加到此文件中.保存文件并重新打开git bash,你的别名应该按预期工作.
此方法允许您为git bash中可用的任何bash命令创建别名,但是正如其他人已经回答的那样,也可以使用git本身创建git特定的别名.
AJ.*_*AJ. 21
您可以设置.gitconfig而不是修改bash_profile,并添加如下所示的别名:
[alias]
st = status
ci = commit
br = branch
co = checkout
df = diff
lg = log -p
Run Code Online (Sandbox Code Playgroud)
Sam*_* Su 11
在主目录中创建.bashrc文件:
touch ~/.bashrc
vim ~/.bashrc
Run Code Online (Sandbox Code Playgroud)
在文件中~/.bashrc
添加别名:
alias gitc='git commit -a'
# -- ... and your other aliases here ...
Run Code Online (Sandbox Code Playgroud)
保存文件(按下<ESC>:wq
vim).重新加载文件,以便bash知道所做的更改:
source ~/.bashrc
Run Code Online (Sandbox Code Playgroud)
这些步骤适用于Win 7/Win 8和Git bash(MINGW32)
小智 5
对于Windows用户:
确保您位于主目录中,最简单的方法是创建.bash_profile
文件并在其中插入别名
注意:要使用记事本对其进行编辑,请首先执行以下行:
git config core.editor notepad
然后创建文件并添加别名,如下所示:
notepad .bash_profile
现在,您可以将别名添加到.bash_profile
like:
别名yourAlias ='您的命令在这里'
别名AnotherAlias ='您的命令在这里'
通过按ctrl+ s 或 File>save
菜单保存文件
归档时间: |
|
查看次数: |
23291 次 |
最近记录: |