git: replay commits on a different path

I’ve done a couple commits in “somedir” and have been continuously rebasing while I worked—my history is linear. Now I wish I hadn’t done my work in “somedir”, but in a separate copy. Can I replay my commits on “anotherdir”, which is an identical copy of “somedir”?
(My commits are on a local topic branch, but that’s not essential to the question.)

  • Git's alternative to .hgrcpath
  • Git: about to fork my own project
  • capistrano - git ls-remote -h doesn't have the git url
  • Unable to symlink to the .git directory
  • Github for Windows ignoring .gitignore file
  • git branch workflow
  • Do not commit specific changes to the git, but also don't revert them from my local workspace
  • How can you tell who merged which branch into git?
  • Why does git checkout “origin/branch-name” lead to “no branch”, in git 1.5?
  • Merging feature branches with several authors
  • What pull requester should do to revert bad commits
  • incremental builds in Xcode server
  • One Solution collect form web for “git: replay commits on a different path”

    You can add anotherdir as a remote of somedir, and push your changes.

    In somedir, assuming the branch with your changes is called current:

    git remote add anotherdir /path/to/anotherdir
    git push anotherdir current

    Then in anotherdir you can checkout the branch current.

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