HiveBrain v1.2.0
Get Started
← Back to all entries
patterngitMinor

Can you remove a commit made to a branch on AWS code commit?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
cancommitmadeyouremoveawscodebranch

Problem

I know of git rebase but don't know if it can be used with AWS code commit?
Or if there's any other method of removing a commit to revert back to before it was made and merged?

Solution

Simplest answer is to just revert the commit. AWS Code Commit is standard Git and will support everything Git allows you to do.

I.e. find commit hash:

git log -n1
commit 444c954e458cc446e2a7a1f2659adf71bdf55580 (HEAD -> my-branch, origin/my-branch)


Then do the revert:

git revert 444c954e458cc446e2a7a1f2659adf71bdf55580
git push


It'll revert your repo to whatever state it would be without that specific commit. Note that if you have other commits that modified the same files afterward, you will have a merge conflict and will have to fix them manually.

Code Snippets

git log -n1
commit 444c954e458cc446e2a7a1f2659adf71bdf55580 (HEAD -> my-branch, origin/my-branch)
git revert 444c954e458cc446e2a7a1f2659adf71bdf55580
git push

Context

StackExchange DevOps Q#13238, answer score: 2

Revisions (0)

No revisions yet.