11/11/2023 0 Comments Git cherry pick from remote repositoryThe cherry-pick command can be used for that: git cherry-pick 2ac430f So we want to add 2ac430f & f761364 commits to this repository. It will output the following results ( commit ids might be different on your run, replace as needed): * f761364 (repoone/master) Add explanation about. ![]() gitconfig): git log -graph -decorate -pretty=oneline -abbrev-commit -all Now when running the following command ( tip: add it as an alias to your. git remote add repoone D:\\gitcherrybetweenrepos\\repoone The D:\\gitcherrybetweenrepos\\repoone will be different depending on your OS and/or file organization, replace as needed. Important: Note that I'm using Windows for the code example so you should escape the \. To start moving changes between the repositories first we need to add it as a remote and download objects and refs from it. config files"įor the next part of tutorial move to the second repository by executing: cd. Add one more change and commit it: echo "_*.config_ files contain the configuration values" > README.md Git commit -m "Add repoone configuration" Now add another change which is only for repoone: echo "This is only for repoone" > nfigĪnd then commit the changes: git add nfig Now make a change in repoone: echo -e "\n\nThis will be moved from one repository to another\n\n" > README.mdĪnd then commit the changes: git add README.md The repotwo directory is a copy of repoone.The repoone directory contains README.md files with the line This line will be the same between both repositories.Tutorial can be easily typed in the terminal, the only difference will be file system changes depending on operating system you are using. It doesn't contain any images as I don't think they are needed. Otherwise the step by step tutorial is available below (I tried my best to make it, but it can be improved a lot, suggestions are welcome). If you feel confident in git, then check a " summary" of commands to get the idea. This gives me quite a good control of what commits to pick up and keeps the history clean. So then I started experimenting with a cherry-pick command. At first experimentation started using rebase, but unfortunately after some bigger changes it began to mess the history. So to save myself from doing any copy-paste I started playing around with different ideas how to do it using git (at least I would be able to play around with a terminal). ![]() Of course the best way would be to move everything to be modular and configurable, but unfortunately in real life this doesn't always happen instantly (you can always dream about it). A difference can be from a simple value to a complete feature. I'm currently refactoring a project which has a lot of similar copies with some slight (most often) differences between them.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |