I am quite new to git and version control in general, and have question about moving files around. I have a master repo on GitHub, with 6 source files.
I've done a lot of work on the project and now my local branch contains two folders with the sources in those.
The directory structure used to be like:
Master:
Where as my local branch now looks like this:
New Folder 1:
New Folder 2:
How can I move my local structure to the master branch without losing my commit history on the old files?
Just commit. Git blame etc will generally do a pretty good job of automatically detecting moves.
git doesn't actually track "moves" of files, it infers it on demand from similar content. So, just make the move and add / remove files as appropriate. (You will make life easier for the tools in future if you avoid making changes to the content as well as moving them in a single commit.)
Then, to see the log accounting for moves, use -M, -C, or their variants to git log. Similar flags apply to other tools, and you should read the help to understand the detail of what they do.
If you use git mv on a file, it just does the git rm and git add for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With