-
-
Save robertlj/eec04a6f193b71ffe56b965b8e0271bd to your computer and use it in GitHub Desktop.
Using JGit in Windows
This file contains 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
1. Download jgit.sh from here: https://eclipse.org/jgit/download/ | |
(Yes -> it's a file with a .sh extension and we want to work in Windows, but download it!) | |
2. Rename the downloaded file to something easier to deal with. E.g. "jgit.sh" | |
3. Create a new file called jgit.bat and stick it in the same folder as jgit.sh. | |
4. Type the following into the jgit.bat file: | |
java -cp %~dp0\jgit.sh org.eclipse.jgit.pgm.Main %* | |
//This will use java to look for the starting | |
//point to start an application whose code is | |
//held within the Main class which belongs to | |
//the org.eclipse.jgit.pgm package. All this is | |
//held within the jgit.sh file... | |
//%* means "use all the arguments from command line prompt here". | |
//%~dp0\ resolves to the folder that the batch script resides within | |
//Add the jgit.bat file to the PATH environmental variable in Windows so that it can be called | |
//from anywhere. | |
5. The code inside the Main instance will look for arguments | |
that are passed in during runtime. Here are the options: | |
jgit --git-dir GIT_DIR --help (-h) --show-stack-trace --version command [ARG ...] | |
The most commonly used commands are: | |
add Add file contents to the index | |
archive zip up files from the named tree | |
branch List, create, or delete branches | |
checkout Checkout a branch to the working tree | |
clone Clone a repository into a new directory | |
commit Record changes to the repository | |
config Get and set repository or global options | |
daemon Export repositories over git:// | |
describe Show the most recent tag that is reachable from a commit | |
diff Show diffs | |
fetch Update remote refs from another repository | |
gc Cleanup unnecessary files and optimize the local repository | |
init Create an empty git repository | |
log View commit history | |
ls-remote List references in a remote repository | |
ls-tree List the contents of a tree object | |
merge Merges two development histories | |
push Update remote repository from local refs | |
reflog Manage reflog information | |
repo Parse a repo manifest file and add submodules | |
reset Reset current HEAD to the specified state | |
rm Stop tracking a file | |
show display one commit | |
status Show the working tree status | |
tag Create a tag | |
version Display the version of jgit | |
7. E.g. you can now execute the following to get the version! | |
F:\#Downloads\JGit>jgit version | |
F:\#Downloads\JGit>java -cp jgit.sh org.eclipse.jgit.pgm.Main version | |
jgit version 4.2.0.201601211800-r | |
8. Add the folder that you have created the jgit.bat file into your PATH environmental variable | |
9. Now create a new file called "secret" and add in the following info from your AWS account: | |
accesskey: XXXXXXXXXXXX | |
secretkey: XXXXXXXXXXXX | |
acl: private | |
You can get the accesskey and secretkey info from your AWS account. | |
Place this file in your Windows user folder... e.g. C:\Users\[username] | |
Make sure the user account you are using has all the appropriate permissions! In particular, check out these examples: | |
http://blogs.aws.amazon.com/security/post/Tx3VRSWZ6B3SHAV/Writing-IAM-Policies-How-to-grant-access-to-an-Amazon-S3-bucket | |
Don't get caught out by not including the permissions for the bucket as well as the content of the bucket!! | |
10. Within your git repo, use regular git to create a remote which points to the S3 bucket. E.g.: | |
git remote add s3 amazon-s3://secret@foo.gitrepos/repo | |
If you want to amend the URL later then just use the set-url command: | |
git remote set-url s3 amazon-s3://secret@foo.gitrepos/repo | |
11. Push up to bucket with jgit! | |
jgit push s3 refs/heads/master | |
12. To clone on another machine with jgit... | |
jgit clone amazon-s3://secret@foo.gitrepos/repo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment