How do I re-commit from a remote branch earlier?

8

I have an application that has some local and remote branchs, but I had to make a git reset --hard HEAD~1 in the dev and development branches (as in the image below) each of these branches have remote ( remotes / dev / master and remotes / origin / development , respectively), and now they are in front of the local branches. How do I align the remote branches with the locations, that is, I want all branches to commit "Removing city from the required parameters" . Is it possible?

Image from my local repository:

Note: When giving push I have a conflict:

! [rejected]        desenvolvimento -> desenvolvimento (non-fast-forward)
error: failed to push some refs to '[email protected]:augustoppimenta/recruti.git'
dica: Updates were rejected because the tip of your current branch is behind
dica: its remote counterpart. Integrate the remote changes (e.g.
dica: 'git pull ...') before pushing again.
dica: See the 'Note about fast-forwards' in 'git push --help' for details.
    
asked by anonymous 16.06.2014 / 18:19

1 answer

7

A quick way to do this is to do a force push after you have done a checkout for the commit you want

Ex.

git checkout <commit_hash>
git push origin desenvolvimento --force

This is probably not the ideal solution if you are working with other people, since the local branch of them will be 2 commits ahead of the remote (which will probably ask them to send the changes back there), which they should do so if it happens, reset the branch to the same version as the remote:

git reset --hard origin/desenvolvimento

Remember that a forced push removes everything in the remote branch and poe what you have locally .. this can generate a number of unwanted effects.

The ideal solution would be to revert commits you do not want in each branch with the command:

git revert <commit_hash>

And then push them to the remote branches

    
17.06.2014 / 02:25