简体   繁体   中英

Git: push into brach such that deleted files are restored

Suppose I have a master branch consisting of finished and unfinished content.

master/
  foo # finished
  bar # unfinished

And I would like to create a release branch from the master branch:

git branch -b release

Where I can strip out all of the unifinished content and leave just the finished material that is ready for release:

git remove bar
vi foo # perhaps make changes

And somehow be in a position where I can update master with changes to foo in release without deleting the files in master that I have deleted in release , and update release with changes to files that I have perhaps deleted in release , but which are now finished in master ...

Is this kind of merge/pull/push relationship possible with git ? Perhaps with some deeper git knowledge and option flags?

You can checkout a new branch add the finished content, stash the unfinished, and add the unfinished to a new branch.

git checkout -b release
git add FINISHED_FILES
git commit -m "My update"
git stash
git checkout -b dev origin/master
git stash pop
git add UNFINISHED_FILES
git commit -m "I am working"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM