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.)

  • Beginner in Git, Starting from Android Studio
  • GitLab v5.0 git push problems
  • Git receive.denyCurrentBranch updateInstead fails
  • Git: resolving merge conflicts
  • Remember GPG password when signing git commits
  • Can't push master branch to git repository with netbeans
  • How do I delete a 'ghost' remote branch in Git?
  • git: I can add a directory, but at commit time I get “nothing to commit”
  • Should I create a Git repo in project source folder or at upper level
  • How to git push using git-emacs?
  • origin does not appear to be a git repository
  • How do I use GitHub through harsh proxies?
  • 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.