Michael Tot Korsgaard
Michael Tot Korsgaard

Reputation: 4014

Git - Force remote branch to match local

So an error happened at my Openshift respository, and now I need to upload the project again, however when I do

git commit -am "some text"
git push

I get the message "Everything is up to date", I now want know how exactly I can force my local version to the remote one at which Openshift uses.

I can see that people are talking about making a "bare" version of the project, but I don't know what they are talking about, and I'm not that familiar with git for me to dare test a whole lot of things, so a nice "ready to use" solution would be gold ;-)


EDIT

As suggested by the comment I tried the ´git push -f origin master` but I get the same result.

Here's a screenshot of my command prompt:image

Upvotes: 7

Views: 17959

Answers (2)

user3159253
user3159253

Reputation: 17455

Well, the situation is pretty clear. You haven't created any new commit yet, so there's nothing to push. Look at that Nothing to commit, working directory clean.

If you really need to create a commit without any change, you may use git commit --allow-empty -m "empty commit". However I'd suggest to create a new file or change an existing one, and commit the changes. After that you may check if the commit was actually created, using git log. Then you may retry the push w/ git push origin master, I'm sure you'll succeed this time.

Upvotes: 3

intboolstring
intboolstring

Reputation: 7100

You are looking for git push -f origin branch-name.

See my other stack overflow answer on how git force pushing works here.

Upvotes: 15

Related Questions