Last active
September 12, 2016 11:45
-
-
Save ncuillery/3447c600d6a33287a3144cfdec480a9e to your computer and use it in GitHub Desktop.
Upgrade React Native on your project, using a git-like interface and without touching the project's local repo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In the root directory of a project using RN 0.32: | |
export GIT_DIR=.gitrn # From this line, all git commands will deal with the .gitrn directory, leaving the .git directory untouched | |
export GIT_WORK_TREE=. # I should tell Git the working tree hasn't changed | |
git init # Create the .gitrn directory | |
git add . # Stage the user's files | |
git reset -- .gitrn # Remove the internal Git files from the index (Git seems to not handle custom GIT_DIR very well...) | |
git commit -m "Project snapshot" # Commit them, the user's files are now known in the new repo index | |
echo "a" | react-native upgrade # Generate the 0.32 template and overwrite all files | |
git add . && git reset -- .gitrn | |
git commit -m "Old version" # Same as before, the 0.32 template is added to the index | |
npm i [email protected] --save # Install the new version of React Native | |
echo "a" | react-native upgrade # Generate the 0.33 template and overwrite all files | |
git add . && git reset -- .gitrn | |
git commit -m "New version" # Same as before, the 0.33 template is added to the index | |
git diff HEAD~1 HEAD > upgrade.patch # Output the diff, totally suitable for the user's project | |
git reset HEAD~2 --hard # Go back to the "Project snapshot" commit | |
git apply upgrade.patch --3way # Git is able to perform a 3-way because the 3 versions of each files have an entry in the index | |
unset GIT_DIR # Restore the default Git directory | |
rm -rf .gitrn # Delete the temporary Git directory. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment