Linux 如何不使用git';s命令

Linux 如何不使用git';s命令,linux,git,Linux,Git,将分支合并到另一个分支后,(如发展为主分支)与 git合并--无ff开发 如果在终端jsut中执行git命令git status,您将看到: On branch master Your branch is ahead of 'origin/master' by 1 commits. (use "git push" to publish your local commit) nothing to commit, working tree clean Wich与此没有太大区别(如果我

将分支合并到另一个分支后,(如发展为主分支)与
git合并--无ff开发

如果在终端jsut中执行git命令
git status
,您将看到:

 On branch master
 Your branch is ahead of 'origin/master' by 1 commits.
   (use "git push" to publish your local commit)

 nothing to commit, working tree clean
Wich与此没有太大区别(如果我们不注意观察):

有时我不太注意,忘记推。那么,有没有命令知道我们是否必须推进?或者,您的分支比“源代码/主代码”提前1次提交。部分是红色的吗


或者,如果需要推送,可能只是返回0或1的命令,如果是,我可以将其与git别名中的
echo
例程一起包含,以使我的
git状态更加明确。

最后,我通过将其放入我的
~/.gitconfig
解决了这个问题:

[alias]
    st = "!f() { git status -u;                                          \
         git status -u | grep \"Your branch is ahead\" > /dev/null       \
         && echo \"\\e[31m[WARNING]\\e[91m You need to push :)\"; }; f"

像这样,只要执行
git st
我就会收到一条红色消息的警告,如果我需要推送。

老实说,你看到的输出
你的分支在前面…
基本上就是你从运行
git status
中得到的输出
git status
通常是您用来找出本地分支机构相对于远程机构的状态(或者至少是本地机构的版本)。
git status | grep“您的分支机构在前面”&&git push
?您还可以在shell提示符中显示回购状态,您必须根据所使用的shell查找相应的说明。@TimBiegeleisen Yes;但是,当您在终端中使用它时,两个输出都是空白的,并且在2-3行中,很容易使difference@jonrsharpe我甚至不去想它,它应该能解决我的问题。用同样的问题回答分享给其他人。另一个简单的git方法是添加一个git别名来做jon提到的事情。按如下方式编辑全局配置:
git config--Edit--global
,在
[alias]
部分(如果缺少该部分,请添加该部分)添加类似
st=!git状态| grep“您的分行在前面”
。注意“!”告诉git它是一个shell命令,这样您就可以使用pipe/grep。。。您可能也可以使用文本颜色代码来突出显示此内容
[alias]
    st = "!f() { git status -u;                                          \
         git status -u | grep \"Your branch is ahead\" > /dev/null       \
         && echo \"\\e[31m[WARNING]\\e[91m You need to push :)\"; }; f"