gitsetup
Github configuration of individual repositories
Borrowed and modified from This Blog.
Download this and run:
chmod a+x gitsetup
to make it executable. Ideally you put this in a folder that is in your path so you can run it from any folder.
Requirements:
- Repo tool-based initial setup
- Fork of desired repository (i.e. frameworks_base, phone, etc..)
- Configured git installation
- Be in top-level folder of the repository you want to configure (i.e. for Phone app, ~/<my_project>/packages/apps/Phone)
Usage:
gitsetup [tracking branch] [new branch] [git@ address for your fork]
or
gitsetup [tracking branch] [git@ address for your fork]
This script will setup your git config (for a particular individual repository) to simplify modifying code and pushing it to your personal fork of that repository.
It will either (depending on the usage):
3 Arguments
- Setup to track changes to [tracking branch]
- Create a new branch named [new branch] based off the tracking branch
- Check out that new branch
- Push an initial commit to your github to create that branch, at the specified git@ address
- Set up an alias for interacting with that fork, defined by MY_REMOTE below
or
2 Arguments
- Setup to track changes to [tracking branch]
- Check out [tracking branch]
- Set up an alias for interacting with that fork, defined by MY_REMOTE below
Note: If you do this, and it has been some time since you originally forked
the repository on github, when you do a git status
you may get a message like:
Your branch is ahead of XXXXX by NN commits
If you see that, simply do a git push [mygit] [branch]
and it will update
the github branch to match your current local branch
The resulting configuration will allow you to perform such things as:
- Allow you to repo sync your entire project (without having to worry about how your individual changes will be affected.
- Pull and push from your Github simply by
entering
git push <my_remote> <branch>
Common things I do once I've set up the git config on a particular repository I'm working on:
- (following a git commit)
git push
... Pushes latest commit(s) to Github git pull --rebase github <tracking branch>
...Re-sync my local copy of the tracking branch, then apply my commits to the end (this keeps the commit history clean, so when it's time to do a pull request, there aren't a bunch merges clouding things up. This is what the repo tool runs on each repository when you do repo sync. By the way, the 'github' in that command is the name the repo tool assigns to the "upstream" address of "git://github.com/"- (following a git commit)
git push --force <myremote> <mybranch>
... resets my Github branch with my local branch, FORCING the local history - basically overwrites the Github copy with my local copy. WARNING: You will lose any history on your Github that isn't also in your local branch. This is generally considered bad form, but I do it before issuing a Pull Request, as I tend to use Github as a "backup" tool, and when I'm all done with stuff, I'd rather have all my changes in a single commit.
One configuration option to make (optional,) at the beginning of the script (after the introductory comments):
MY
_REMOTE="mygit"
Enter a simple name to make pushing/pulling easier. This will NOT be seen publicly. It simply replaces having to enter git@github.com:<you>/<yourfork>
every time you want to interact with your fork. Instead you can just enter git push mygit <myfork>
and so on.
appinstall
Script for repeatedly reinstalling a system app to your phone for testing in an Android source build environment.
Download this and run:
chmod a+x appinstall
to make it executable. Ideally you put this in a folder that is in your path so you can run it from any folder.
Requirements:
- Repo tool-based initial setup
- Fully compiled source (with ‘out’ folder structure for your device)
- Functional ADB (Android Debug Bridge) interface to your phone
Usage:
appinstall [apk name] [up OR push]
Where:
[apk name]:
- Name of system app without the .apk extension (Phone, Contacts, etc..) Case sensitive!
[up | push]:
up
– Will perform aninstall –r <apk name>
to update the app. Note that this can sometimes cause the app to Force Close due to permissions issues. Also, upon reboot, the ‘updates’ will be lostpush
– Will perform a pull/push to completely replace the app. This requires a reboot for replacement to take effect
Required variable settings in script:
ANDROID
_ROOT:
Path to the root folder of your Android source tree (i.e. /mike//bin/android)
BUILD
_DEVICE:
Engineering name for the device you’re testing on (i.e. sholes, passion, etc…)