[英]Copy all files from master to another branch in git
我只需要將master
分支中的所有文件復制到production
分支,並在那里生成縮小的代碼等,並在production
檢查。
我不想合並,而只復制文件。
我試圖在Google中搜索,但感到困惑。
我正在遵循這種粗略的方法:
#currently I'm in master branch in current directory
rm -rf /tmp/production
cp -r . /tmp/production
rm -rf /tmp/production/.git
git checkout production
cp -r /tmp/production/* .
有任何單行命令嗎?
git checkout master
cp -r . /tmp/production
rm -rf /tmp/production/.git
git checkout production
cp -r /tmp/production/* ./copy_of_production
我認同。
您可以重用“ 如何將一個遠程分支覆蓋(而不是合並)到另一個分支? ”中的方法。
git checkout production # First, merge master into production so we have
git merge -s theirs master # a merge commit to work with.
git checkout master # Then, flip back to master's version of the files
git reset --soft production # Then we go back to the merge commit SHA, but keep
# the actual files and index as they were in master
git commit --amend # Finally, update the merge commit to match the
# files and index as they were in master.
它不是一行,但是它確實記錄了master
覆蓋production
內容的事實。
您可以輕松地做的是,在創建分支生產時,您將定位到母帶,然后可以推送原始生產。
例:
git checkout -b production //to create branch production
git checkout master // to be positioned on the master
git push origin production
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.