github - undoing several commits to just one in git -


i made contribution open source project on github , received, didn't conform commit message standards asked so, , instead of doing 1 change per commit, should make 1 commit changes proposed in it.

so, how can undo previous commits , 1 changes in it?

you can use git interactive rebase "squash" commits one.

# squash 2 commits git rebase -i head~2 

or

# squash specific commit identified it's sha1 git rebase -i a3ea79f 


if have commit history this:-

git log --oneline --decorate  * d6f7bbd (head, master) added test2 * 35dde7a added test1 * a3ea79f initial commit 


rebasing either of rebase commands above open editor. , modifying "pick" lines adjust commits:-

pick 35dde7a added test1 pick d6f7bbd added test2  # rebase a3ea79f..d6f7bbd onto a3ea79f # # commands: #  p, pick = use commit #  r, reword = use commit, edit commit message #  e, edit = use commit, stop amending #  s, squash = use commit, meld previous commit #  f, fixup = "squash", discard commit's log message #  x, exec = run command (the rest of line) using shell # # these lines can re-ordered; executed top bottom. # # if remove line here commit lost. # # however, if remove everything, rebase aborted. # # note empty commits commented out 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -