4

git status reports:

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

Is there a configuration file or some other way to override that message? Especially removing the "git push" reference? I don't want people to use "git push" but rather to use a different tool.

1 Answer 1

2

See if this works:

git config advice.statusHints false

Addressing your comment as to whether some messages can be printed but not others:

No. Sorry, but this behavior is hard-coded into git. The same variable (advice_status_hints) is used to determine whether each message is printed. The only way to do this with git would be to create your own fork of git, edit the code, and build from source.
However, there is a hacked-together solution that involves redefining git to be a function in .bashrc:

git() {
    if [[ $1 == "status" ]];
    then
        command git "$@" | sed '/# (use "git push" to publish your local commits)/d'
    else
        command git "$@";
    fi;
}

It's not elegant, but it works by deleting the matching line if the command is git status.

Sign up to request clarification or add additional context in comments.

2 Comments

Right direction. But I'd like the users to still get other messages. For example when there is modified files but nothing added, status gives a useful hint of '(use "git add" and/or "git commit -a")'
@TomO This isn't possible using git, but there is a bash solution (see my post).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.