Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8481377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:32:44+00:00 2026-06-10T19:32:44+00:00

When a branch history is changed on the remote, you typically get o git@git.server.com:XXXXX/Project.git

  • 0

When a branch history is changed on the remote, you typically get

o git@git.server.com:XXXXX/Project.git
 + efe2e8b...cda0ee7 HEAD -> Ant_Config_processing (forced update)

Is there any way to get this (forced update) status using scripting ?

The idea is to write an alias that detects it and prompt the user for actions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T19:32:45+00:00Added an answer on June 10, 2026 at 7:32 pm

    I have a similar problem and I figured out it.

    I want to detect forced update within hook script in remote (bare) repository, So my answer might not be suitable for original question, but I hope to be useful my answer for future visitors.


    How to detect forced update or not from in Git hooks script

    https://github.com/kyanny/git-hooks-detect-force-update

    This is a sample git pre-receive hook script for learning about how to detect forced update.

    Conclusion

    $ git rev-list oldrev ^newrev
    

    How to test

    $ rake -T
    rake forced_push  # git hooks test detect forced update
    rake normal_push  # git hooks test
    

    Step-by-Step introduction

    Firstly, I describe a syntax of git-rev-list(1).

    In this case, we assume within a Git working repository that has this straight history.

    1 --- 2 --- O --- X --- 3 --- 4 --- N
    

    General usage of git-rev-list is below.

    $ git rev-list N
    

    This command will show all of commits reachable from commit N (note: git-rev-list shows commits reverse chronological order)

    git-rev-list accepts multiple arguments.

    $ git rev-list N O
    

    This command will show same output as git rev-list N, because commit O is an ancestor of commit N.

    Then, git-rev-list allows you to exclude commits from output.

    $ git rev-list N ^O
    

    ^O means that to exclude commits reachable from O, so this command will show N, 4, 3, X (note: O is excluded)


    Since we are learned about git-rev-list, I describe a case about forced update occured.

    In this case, we assume within a Git working repository that has this complex history.

    * --- B --- * --- O ($oldrev)
           \
            * --- X --- * --- N ($newrev)
    
    1. In old tree, we had 4 commits (*, B, *, O) and pushed them to remote.
    2. We checkout a new branch from commit B, it’s new tree.
    3. In new tree, we had 4 commits (*, X, *, N) and pushed them to remote with –force option!

    When pushed, hook pre-receive script invoked with standard input. The format of stdin parameter is described at githooks(5).

    Typically, we extract two commit object sha1 from stdin – oldrev and newrev. oldrev is HEAD of old tree, newrev is HEAD of new tree.

    In this situation, we can detect forced push by git-rev-list output.

    git rev-list oldrev ^newrev shows the commits reachable from oldrev but not reachable from newrev. This shows the commits existed only old tree.
    If this command show any commits, old tree was replaced with new tree, so forced update was occured. This is what we want!

    If this command show none of commits, new tree was normally updated, so forced update was not occured. Simply.

    See Also

    • git-rev-list(1)
    • Git hook example: post-receive-email
    • git – How to detect a forced update – Stack Overflow
    • githooks – Git hook to detect push –mirror – Stack Overflow
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I delete a commit from my branch history? Should I use git
On a git/github project I am working on a branch. Upon a push, it
To git@github.com:xxx/xxxxx.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs
View History on an file in a branch show only changes since the branch.
I have to remove a branch from svn history for good. Normally I would
I have my branch on my GIT repository where I used to commit and
I have a git branch that is based off an old master. This branch
In the master branch of our project, the migrations of one of our django
I have created branch with git checkout -b mybranch. It seems that something went
I have a local branch named ' my_local_branch ', which tracks a remote branch

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.