2

I simply need to copy all files in the master branch to production branch and generate minified code etc there and check it in production.

I don't want to merge but only copy the files.

I tried to search in Google but I'm confused.

I'm following this crude method:

#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/* .

Is there any single line command for this?

user5858
  • 1,082
  • 4
  • 39
  • 79

2 Answers2

0

You could reuse a method from "How can I overwrite, not merge, one remote branch into another branch?"

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.

It is not one line, but it does record the fact that master override production content.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
-2

The easily thing you can do is when you create your branch production, you will positioned to master then you can push origin production.

Example:

git checkout -b production //to create branch production
git checkout master // to be positioned on the master 
git push origin production
cmnardi
  • 1,051
  • 1
  • 13
  • 27