• Home
    • View
    • Login
    This page
    • Normal
    • Export PDF
    • Page Information

    Loading...
  1. Dashboard
  2. Undefined Space
  3. Skara
  4. FAQ

FAQ

  • Created by Erik Helin, last modified on Mar 09, 2020

Git

Configuration

How do I configure my full name?

$ git config --global user.name "Full Name"

How do I configure my email?

$ git config --global user.email "full.name@company.com"

How do I configure my text editor?

$ git config --global core.editor "vim"

Repositories

Cloning

How do I clone a repository?
$ git clone <URL>
How do I clone using SSH?

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
How should I structure my local clones of repositories?

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
Can I have multiple local clones of a repository?

Yes, this is supported, supply a second argument to git clone stating the directory name of the local repository:

$ git clone <URL> <DIRECTORY>

Branches

How do I create a local branch?
$ 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>

What should I name my local branches?

A common way of structuring your local branches is to name them after the issue they correspond to, for example JDK-8237566.

How do I list local branches?
$ git branch
  JDK-8237566
* JDK-8149128
  JDK-8077146
  master

The currently checked out branch has an asterisk ("*") next to it.

How do I visualize branches in a graph?
$ git log --format=oneline --graph --all
How do I switch to another branch?
$ 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>

Can I have different branches checked out in different local repositories?

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

GitHub

Configuration

How do I setup two-factor authentication (2FA)?

https://help.github.com/en/github/authenticating-to-github/securing-your-account-with-two-factor-authentication-2fa

How do I generate a personal access token (PAT)?

Go to https://github.com/settings/tokens and and click on "Generate new token"

How do I upload an SSH key to my GitHub account?

https://help.github.com/en/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account

Overview
Content Tools
ThemeBuilder
  • No labels

Terms of Use
• License: GPLv2
• Privacy • Trademarks • Contact Us

Powered by a free Atlassian Confluence Open Source Project License granted to https://www.atlassian.com/software/views/opensource-community-additional-license-offer. Evaluate Confluence today.

  • Kolekti ThemeBuilder Powered by Atlassian Confluence 8.5.21
  • Kolekti ThemeBuilder printed.by.atlassian.confluence
  • Report a bug
  • Atlassian News
Atlassian
Kolekti ThemeBuilder EngineAtlassian Confluence
{"serverDuration": 195, "requestCorrelationId": "e4612d1cd415bd59"}