- Loading...
$ git config --global user.name "Full Name"
$ git config --global user.email "full.name@company.com"
$ git config --global core.editor "vim"
$ git clone <URL>
Make sure you have uploaded an SSH key to your GitHub account and then run:
$ git clone git@github.com:path/to/repo.git
For example, to clone the jdk repository over SSH:
$ git clone git@github.com:openjdk/jdk.git
If you don't want to type git@github.com
every time, add an entry to your SSH configuration.
A common way of structuring local repositories is by following the domain name and path convention. For an example, see below:
$ tree . ├── git │ └── github.com │ ├── edvbld │ │ ├── jdk │ │ └── loom │ └── openjdk │ ├── jdk │ ├── loom │ └── valhalla └── hg └── hg.openjdk.java.net ├── code-tools │ └── jtreg └── jdk └── jdk
Yes, this is supported, supply a second argument to git clone
stating the directory name of the local repository:
$ git clone <URL> <DIRECTORY>
$ git checkout -b <NAME-OF-BRANCH>
If you are using Git version 2.24 or newer you can also use the command: git switch --create <NAME-OF-BRANCH>
A common way of structuring your local branches is to name them after the issue they correspond to, for example JDK-8237566.
$ git branch JDK-8237566 * JDK-8149128 JDK-8077146 master
The currently checked out branch has an asterisk ("*") next to it.
$ git log --format=oneline --graph --all
$ git checkout <NAME-OF-OTHER-BRANCH>
If you are using Git version 2.24 or newer you can also use the command: git switch <NAME-OF-OTHER-BRANCH>
Yes, this is supported. If you prefer to have one local repository per issue you are working on, then you would have a local repository and a local branch per issue you are working on. For example:
$ git clone https://github.com/<USERNAME>/jdk JDK-8123456 $ cd JDK-8123456 $ git checkout -b JDK-8123456
To create the first local repository representing the work on issue JDK-8123456. To create a second local repository for JDK-8654321, run:
$ git clone https://github.com/<USERNAME>/jdk JDK-8654321 $ cd JDK-8654321 $ git checkout -b JDK-8654321
$ git push --set-upstream <REPOSITORY> <LOCAL-BRANCH>
For example, if the repository you want to push corresponds to the remote named origin and your local branch is named JDK-8123456, you would run the following command:
$ git push --set-upstream origin JDK-8123456
If you are using the Skara CLI tools then and have the branch you want to publish currently checked out, then you can just run the command git publish
Go to https://github.com/settings/tokens and and click on "Generate new token"
A personal fork is a copy of another repository with one major difference:
Assuming you have a local clone of your personal fork and you are using the Skara CLI tools:
$ git sync
If you also want to sync your personal fork and your local clone of your personal fork and you are using the Skara CLI tools you can run:
$ git sync --fast-forward
If you do not have the Skara CLI tools installed and you have a local clone of your personal fork, you need to the following steps:
$ git remote add upstream <URL-FOR-ORIGINAL-OPENJDK-REPOSITORY> $ # for each branch you want to sync $ git checkout <BRANCH> $ git pull upstream <BRANCH> $ git push origin <BRANCH>
A pull request is a way to suggest that some changes from a personal fork should be incorporated into the original repository the personal fork was created from. Reviewers can comment upon and need to approve a pull request before it can be integrated. The concept of a pull request is very similar to OpenJDK's concept of "RFR" emails - both are used to suggest changes and offer a way for reviewers to provide feedback on the suggested changes.
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Note: pick a strong password for your key. You will not have to type your password every time you want to use your SSH key if you use the SSH agent.
You use the ssh-agent. An ssh-agent should already be running if you are using GNU/Linux, macOS or Windows 10 (since version 1803). To add a key to the ssh-agent
, run ssh-add
:
$ ssh-add /path/to/the/private/key
If you want the key to exist in the ssh-agent
only for a limited time, use the -t
(for timeout) option:
$ ssh-add -t SECONDS /path/to/the/private/key
$ ssh-add -l
$ ssh-add -d /path/to/public/key
Note: if the only difference in filenames between the private key and the public key is that the public key ends in .pub
, then you can use the path to private key in the above command as well.
Yes, by adding a host alias for github.com in your SSH configuration file ~/.ssh/config
. Add the following lines to ~/.ssh/config
:
Host github.com github gh User git Hostname github.com
You can now clone from GitHub using the aliases listed after Host
:
$ git clone github.com:openjdk/jdk $ git clone github:openjdk/jdk $ git clone gh:openjdk/jdk