Created
September 12, 2012 11:33
-
-
Save nverinaud/3706079 to your computer and use it in GitHub Desktop.
Git workflow: project with libraries
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
# Add a library | |
$ git remote add -f lib/[libname] [lib-remote-URL] # Add the lib remote and fetch | |
$ git read-tree --prefix=lib/[libname]/ -u lib/[libname]/master # Import the library files | |
$ git commit -m "Add [libname] library." # Commit the added library | |
$ git push # We're done ! | |
# Update to the latest version of a library | |
$ git pull -s subtree --squash --no-commit lib/[libname] master # Update files of the library | |
$ git commit -m "Update [libname] library." # Commit the update in master | |
$ git push # We're done ! | |
# Useful aliases | |
[Alias] | |
lib-remote-add = "!f() { git remote add -f lib/$1 $2; }; f" # Add and fetch a remote | |
lib-import = "!f() { git read-tree --prefix=lib/$1 -u lib/$1/master; }; f" # Import files from the remote (you must call lib-remote-add before) | |
lib-add = "!f() { git lib-remote-add $1 $2 && git lib-import $1 && git commit -m \"Add $1 library.\"; }; f" # Combine lib-remote-add and lib-import and commit changes automatically | |
lib-update = "!f() { git pull -s subtree --squash --no-commit lib/$1 master && git commit -m \"Update $1 library.\"; }; f" # Update the specified lib and commit the update automatically | |
# Add a library with above aliases | |
$ git lib-add [libname] [lib-remote-URL] | |
# Update to the latest version of a library with above aliases | |
$ git lib-update [libname] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Inspired by: