18

Using version 1.0.4, I can't find any force push option. Is command line the only way to use force?

Can't push and Can't pull

Community
  • 1
  • 1
JeffBship
  • 417
  • 1
  • 3
  • 10
  • That option might be available now: see [my edited answer below](https://stackoverflow.com/a/53343983/6309). – VonC Aug 05 '20 at 13:56

6 Answers6

12

As of Nov. 2018, still no native support for a push --force in GitHub Desktop:

That might change, considering GitHub is now displaying who did a push --force on GitHub.

Update August 2020, issue 3580 mentioned above now include this screenshot, by turtlemaster19:

Interestingly, in the Advanced preferences of GitHub Desktop (at least on Mac) there is this interesting checkbox:

https://user-images.githubusercontent.com/46784000/89301809-b19ec200-d62f-11ea-902b-1d4fd1663853.png

VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755
4

If you only need to force-push just once, and are familiar with the command line, you could do this:

  1. Open the Github Desktop logs via "Help" > "Show Logs in Finder"

  2. Now perform a Push in Github Desktop

  3. You'll see what command the app is trying to perform in the logs window, e.g.:

    [ui] Executing push: git -c credential.helper= -c protocol.version=2 push origin main:main --progress (took 1.441s)

  4. Copy that call to the 'git' CLI and add a --force parameter

  5. Open a Terminal window and navigate to the folder of your local repository

  6. Perform the copied git command, and when asked for credentials, use the Github credentials you've used to login on the website

Raffael
  • 1,093
  • 9
  • 19
  • 2
    If you're getting "remote: Support for password authentication was removed on August 13, 2021" then [create access token](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token), check "public_repo Access public repositories" in token "Select scopes" and use the token instead of your password when prompted. – artifex Aug 14 '21 at 18:22
2

After spending some time found force push in Github Desktop Mac, (not sure about Windows)

STEP-1: Switch to history, tab.

enter image description here

STEP-2: Then click and drag one commit over the other. Squash commit popup will come, choose accordingly.

https://user-images.githubusercontent.com/19490960/160462212-b9b2fd47-67d7-4796-8ea5-6dbe482536b0.png

STEP-3: Now you will be able to see force push

enter image description here

Hope this helps, Happy Coding!

1

Ran into this same issue, was able to "force" push the changes I made by using the 'upload files' feature on github. Didn't sync my local repo, but it at least got the files in the repo for me to use on another machine. Not the ideal solution I'm sure, but it worked for my purposes, in case it can help someone else.

enter image description here

AWP
  • 91
  • 2
  • 6
1

GitHub Desktop actually have a force push feature. When you click "History" on Repository page, you can drag a one commit before another one which will cause force push to repository. There is no feature that you have requested at all, but it seems application is on a good way to have such thing.

keinsell
  • 131
  • 11
-16

Yes you can do

git push origin <your_branch_name> --force

Update!

This option worked hence accepted answer but no longer works in later versions of Git.

Darragh Blake
  • 230
  • 1
  • 5