首页 > 解决方案 > 如何在不使用 git 命令的情况下推送

问题描述

将分支合并到另一个分支后(如发展为主分支) git merge --no-ff develop

如果你git status在终端 jsut 中执行 git 命令后你会看到:

 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 与此没有太大区别(如果我们不注意看的话):

 On branch master
 nothing to commit, working tree clean

有时我不太注意,我忘了推。那么是否有命令知道我们是否必须推送?或一种将Your branch is ahead of 'origin/master' by 1 commits.零件涂成红色的方法?

或者如果我们需要推送,可能只是一个返回 0 或 1 的命令,如果是,我可以将它包含echo在 git 别名中的例程中以使我git status更明确。

标签: linuxgit

解决方案


最后,我把它放在我的~/.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如果我需要推送,我会通过执行红色消息来警告我。


推荐阅读