1

git-2.16.2 on linux

I'm not terribly experienced with git push, so please bear with...

I made changes to a clone which was created from origin master. I want to push those changes to origin master without merging with what's there. I tried git push --force but that didn't seem to work even though the messaging seems to indicate that it did...

--> git push --force
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 597 bytes | 597.00 KiB/s, done.
Total 4 (delta 1), reused 0 (delta 0)
To /proj/projects/git_repos/mytool.git
 + eafc0ab...3155ce8 master -> master (forced update)

I say it didn't work because when I now do a git clone of origin master to make a new repo with the changes, the changes aren't there.

The reason I tried the --force is that I want all my local (committed) changes to basically clobber whatever's in origin master. I don't want to merge with whatever's there, although I can see why that's an important thing to be able to do in some circumstances. I'm basically looking for a shortcut around doing the git pull --rebase and all the merging (accepting everything I have locally and rejecting everything else), git add, git rebase --continue, etc... . I just want my local changes to replace whatever's in the origin master.

If there is a shortcut outside of git push --force that I can use to to avoid all the merging and just accept the local changes, that's good, because it'll save the history.

Thanks for any help

Caleb
  • 124,013
  • 19
  • 183
  • 272
daveg
  • 1,051
  • 11
  • 24
  • 1
    Are you sure you're cloning from the right repo? Your operations seem fine to me. – iBug Apr 21 '20 at 17:18
  • You may find a solution in [this related question](https://stackoverflow.com/questions/40517129/git-merge-with-force-overwrite). – ingernet Apr 21 '20 at 17:20

1 Answers1

0

OK, I think my mistake was that I did a "git push --force" and not a git push --force origin master". Not sure where things get pushed to, but that appears to have worked.

daveg
  • 1,051
  • 11
  • 24