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 6621299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:14:43+00:00 2026-05-25T21:14:43+00:00

I just did a git push -f without including the branch I intended to

  • 0

I just did a

git push -f 

without including the branch I intended to push and git just blasted in everything to my repo. Fortunately we could piece together the old repo without to much trouble but it would be nice if I could change a setting in git to prevent -f all or make it so I have to do it explicitly.

Anyone aware of a setting I can change for this?

  • 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-05-25T21:14:43+00:00Added an answer on May 25, 2026 at 9:14 pm

    You can setup a pre-receive hook on the remote repo, that can prevent force push. You can also ensure that force push can only be done if explicitly specifying a particular branch.

    You can also setup your local repository to change the default behaviour of the git push so that it will push only the current branch:

    For example, to default to pushing only the current branch to origin
    use git config remote.origin.push HEAD. Any valid (like the
    ones in the examples below) can be configured as the default for git
    push origin.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just did git pull origin branch accidentally and now I have all these
I just did my first ever git push : ~/sb/ws> git push ~/gitrepo master:master
I just squashed some commits with git rebase and did a git push --force
I just did an svn merge from a branch to a trunk in my
I had a lot of local changes. I just accidentally did git merge another_branch
On branch 'first' I did: git add . git commit -m Finished first changes
I just did something dumb. In my fooclient project, I just did: git remote
I just did a git init on the root of my new project. Then
I just did a git commit -m blah then I added some files, how
I have a big problem with git-svn: I need to just push my git

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.