Reputation: 9599
If I had to following file on my development branch:
# file.rb
class Code
def methodA
'aA1'
end
def methodB
'bB2'
end
end
but on my master branch I wanted to separate the methods into different files:
# in file.rb
class Code
def methodA
'aA1'
end
end
# in extra.rb
class Code
def methodB
'bB2'
end
end
I could simply create the file on development, then checkout to master, rebase and separate the file manually, but is it possible set things up so that when I make changes to development it would be carried over to the right "part" of the file on master?
Upvotes: 10
Views: 3311
Reputation: 1323773
To have a split "carried over to the right "part" of the file on 'master
'" would imply Git being able to detect the split.
And as illustrate by this recent thread (this month: May 2009), Git is not quite there yet.
That might work for big files with a small part in it split to another file, but for small files, the content appears "too different" for git rename detector to pick up the changes.
So rebase
'master
' on top of 'development
' might work, provided you did not publish (push
) 'master
' since 'development
' has been made, because such an operation (rebase
) will rewrite the SHA-1 of commits on 'master
' branch (since they are replayed on top of commits of the 'development
' branch)
As I described in rebase vs.merge, if your development branch is not "too far" (in term of modifications from master, another strategy would be to rebase development on top of master, make the split, and then merge development back to master (fast-forward merge at this point)
Upvotes: 4