How to un-commit the last n commits?

I’m working on a tree which has the following commits:-

aaaaaaa Implement function A
bbbbbbb Implement function B
ccccccc Implement function C

I would like to un-commit the first two , that is , to put these changes again into the staging area. I’ve learnt that git reset --soft HEAD^ would un-commit the last commit. But I would like to know the way to do it for many commits at once. I’m not sure if git reset --soft HEAD~10 would un-commit the 10th from the last commit or un-commit the last 10 commits.

  • How to link already existing TFS-git commit to TFS work item?
  • Difference between “Force” and “Override branch if exists” in Tortoise Git
  • git is ignoring files that aren't in .gitignore?
  • How to retrieve untracked files with git stash
  • Ionic/Cordova: How to install plugin into existing project?
  • Git mirror without forced pushes
  • Prune all git remotes
  • How to update my working Git branch from another branch (develop) ?
  • Should I delete the LOCAL remote/origin/master branch after I have merged it with my local master?
  • git rebase -i with gvim doesn't wait for me to save?
  • Rails 4: Heroku push rejected / Gemfile Issues / GIT Issues
  • Git is doing very slow commits on a Samba share. What can I do to speed it up?
  • One Solution collect form web for “How to un-commit the last n commits?”

    First, be sure that none of the commits you’re trying to change have been pushed to the public repository. (From the sounds of it, they have not yet been made public.)

    You’re on the right track with git reset --soft HEAD^.

    HEAD^ is one commit before HEAD. HEAD~4 is four commits before HEAD – or, altogether, five commits back.

    Found on GitHub blog

    Git Baby is a git and github fan, let's start git clone.