Reputation: 1538
I have a branch (say branch_a), merged to master. But after I have merged, I found that I have to revert back for now to do some database updates. After the database updates, I will merge them again.
My problem is that I have a branch with the new files and changed files (reverted files) but when I try to commit it always say nothing to commit.
how can I redeploy the same branch again?
Upvotes: 1
Views: 55
Reputation: 6693
This is not a problem that --reset
will fix. The OP's issue is that he merged a branch, then used git revert
to revert the effect of the the merge. git revert
introduces a NEW set of commits that reverse the effect of the reverted commits, leaving the original commits in the branch.
This is a problem if you then try to re-merge the same branch again. The commits already exist in your target branch (even though they've been nullified by the later reversion), and so git merge
refuses to merge them a second time - they're already there.
However, if your commits on the branch that you want to merge in had new hashes, they'd appear to be new commits and would merge as desired. There are a couple ways to accomplish that. For instance, git cherry-pick
actually creates NEW commits with new hashes. You can make a new branch, cherry-pick the commits you want onto that, and then merge that to master.
Cherry-picking multiple commits: How to cherry-pick multiple commits
For more details (including the official solution, rather than my rather hackish one): Re-doing a reverted merge in Git
Upvotes: 1
Reputation:
The quickest way to reset the changes or revert back for your database updates.
git-reset - Reset current HEAD to the specified state
See this Git Docs: git reset --hard ORIG_HEAD
And also check
git log
for any rebased commit messages.
The reason I guess, you are unable to commit changes is? you might have skip git add .
. See this post
Upvotes: 0
Reputation: 59
Go back to the most recent commit PRIOR to merging in the branch. To see your git commit history:
$ git log --oneline --graph --decorate --all
This will give you a list of commits. Copy the commit short code (say it is ABC123) immediately preceding the merge. Simply type
$ git reset ABC123
That should take you back to where you were prior to the merge. If that doesn't work, google "git reset --hard". Make sure you are ok with how a hard reset works. If you are, type in:
$ git reset --hard ABC123
But $ git reset ABC123 should do the trick for you. Good luck
Upvotes: 0