Reputation: 5453
I'd like to copy a file from one git branch to another but save it as a different filename. I know I can do this to copy it over with the same name. Is there a way to rename during the checkout?
git checkout otherbranch myfile.txt
Upvotes: 4
Views: 291
Reputation: 1261
let's understand with an example: if you want to copy the index.html file from the master branch to develop branch with different file name then
step-1: checkout to develop branch
git checkout develop
step-2: copy file from master to develop branch
git show main:index.html > new_index.html
step-3: add this new file
git add .
step-4: commit file
git commit -m "message"
step-5: and push file
git push
Upvotes: 1