How can I selectively merge or pick changes from another branch in Git?

前端 未结 25 2135
慢半拍i
慢半拍i 2020-11-22 02:53

I\'m using Git on a new project that has two parallel -- but currently experimental -- development branches:

  • master: import of existing codebase pl
25条回答
  •  佛祖请我去吃肉
    2020-11-22 03:04

    If you don't have too many files that have changed, this will leave you with no extra commits.

    1. Duplicate branch temporarily
    $ git checkout -b temp_branch

    2. Reset to last wanted commit
    $ git reset --hard HEAD~n, where n is the number of commits you need to go back

    3. Checkout each file from original branch
    $ git checkout origin/original_branch filename.ext

    Now you can commit and force push (to overwrite remote), if needed.

提交回复
热议问题