I am looking to move a folder so that it resides in another folder.
Currently: /folder1, moved to /holder/folder1, for example.
What is the easiest way to do this both on my home machine (Mac) and git to ensure that all of the history of the files within that folder remain on github.
Sorry for the newb question. I have only a very basic working knowledge of git, and would like to keep this as simple as possible.
Thanks!
Merge the files into the new repository B. Step 2: Go to that directory. Step 3: Create a remote connection to repository A as a branch in repository B. Step 4: Pull files and history from this branch (containing only the directory you want to move) into repository B.
Git move or mv helps us to rename or move files within a git repository without deleting its history.
Git keeps track of changes to files in the working directory of a repository by their name. When you move or rename a file, Git doesn't see that a file was moved; it sees that there's a file with a new filename, and the file with the old filename was deleted (even if the contents remain the same).
Use git status to check the changes staged for commit. Commit the file that you've staged in your local repository. $ git commit -m "Move file to new directory" # Commits the tracked changes and prepares them to be pushed to a remote repository.
From git documentation,
git mv [-f] [-n] <source> <destination>
git mv [-f] [-n] [-k] <source> ... <destination directory>
In the first form, it renames , which must exist and be either a file, symlink or directory, to . In the second form, the last argument has to be an existing directory; the given sources will be moved into this directory.
The index is updated after successful completion, but the change must still be committed.
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