If your company is fortunate enough to use GitHub Enterprise, then this quick setup how-to may be useful to you, at least when you’re starting out.
Authentication of the web UI and git command line are different. For the web UI, you will be prompted for your corporations’ intranet credentials. With enterprise SSO these will be the same credentials you use to gain access to all internal resources. However web SSO doesn’t work so well with command line tools. When git prompts for credentials, your intranet username and password won’t be recognized.
To use HTTPS you will need to generate an OAuth access token to be used as an HTTP basic auth password. This can be done from the GitHub Enterprise settings for your account.
Your token will look something like this: 1eef2871dd78346b8ba07f5ff10f7504f9da0619 [not a real token]
That unweildy token becomes your git repo password. To avoid entering this more than once, configure git to use the MacOSX Keychain to store the password securely. You will need to manually enter this password only once. Then you should see it added to your keychain, which git will use hereafter. If your OS has no native keychain, you can have git use another credential helper that will cache or even locally store the password instead, though these options are less than ideal.
In the scenario below, we setup the git command line, point it to a remote but empty repo, download that repo, add our initial set of files for our project and commit it back to the remote repository. The first time we interact with git it will ask us for our credentials (username+token), but afterwards the credentials will be taken from the keychain.
# create the local repo $ git init $ git config --global user.name "John Smith" $ git config --global user.email "firstname.lastname@example.org" $ git config --global credential.helper osxkeychain # check out the configuration $ git config -l # git remote add <name-of-remote-repo> <url.git> # where <name-of-remote-repo> is typically "origin" # and <url.git> is "https://github.mycompany.com/jsmith/myrepo.git" # (omit quotes) $ git remote add origin https://github.mycompany.com/jsmith/myrepo.git Username: <your email> Password: <enter the token here> $ git pull origin master # this just pulls down the contents of an empty repo <add your files> $ git add * $ git commit -m "Initial commit" # commits to local repo $ git push origin master # synchronizes with remote git repo
Now that you’re setup you can quickly learn the basics of git from this excellent resource.