While developing an application, I would like to have at one point a separate copy of my work for experimenting with several changes. Theses changes are not meant to be committed! It's just playing around, to try out various possibilities.
What is the "best" way to do this? I found the following possibilities, but would like to get the advice of people who have more experience with git than I do:
git clone
to get a copy of the repository into a different directory, and use it to play around.cp -r
my current git working directory to the new one.In case (1), git is aware about the clone, and I could later rebase
if I really would want to, but it is unlikely that I will ever do this.
In this case, is there something I should be aware of, which makes either solution (1) or (2) preferable? Or is there an even better way to do it?
Yes you can, but there's no need to copy the full working tree. You can copy just the . git folder without the working tree (i.e. as a "bare" repo) and then checkout the latest working tree on the other machine.
The best way is to create your own branch from the current state, do your work on this branch (with commiting if you want). At the end, if you want to have your work with the main branch, you could run a git merge
.
To create a branch from the current state, just run git checkout -b my_branch
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