1

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?

JumpMan
  • 2,016
  • 3
  • 22
  • 37
Karim Samir
  • 1,184
  • 12
  • 15
  • Did you try git add . before you commit, you must add it. See this [post](http://stackoverflow.com/questions/5931505/why-is-there-nothing-to-commit-after-i-added-my-new-directory) – JumpMan Sep 18 '15 at 03:56
  • yes , I tried the branch doesn't show anything new. – Karim Samir Sep 23 '15 at 00:26

3 Answers3

1

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

Community
  • 1
  • 1
S McCrohan
  • 6,277
  • 1
  • 26
  • 35
0

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

Community
  • 1
  • 1
JumpMan
  • 2,016
  • 3
  • 22
  • 37
0

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

Utah
  • 39
  • 1