Git/Guide

From Hack Manhattan Wiki

Setup Git

Follow Installing Git to learn how to install Git on your operating system.

Now that you have Git installed, it’s time to configure your personal information. You should have to do this only once. You can also change your personal information at any time by running these commands again.

Git tracks who makes each commit by checking the user’s name and email.In addition, this info is used to associate your commits with your Forgejo account.

Currently, for beginners, we only need the following two arguments:

  • git config --global user.email "your@email.com"
  • git config --global user.name "Your Name"

Onboarding

For beginners, here is a quick HTTP method for accessing the repository.

  1. Open a terminal or command prompt on your local machine, and clone the repository:
    git clone http://192.168.42.170:3000/SAGroup/sysadminrepo.git
  2. Navigate to the folder: cd sysadminrepo
  3. Do edits, and git add . && git commit -m "useful message"
  4. Update your local copy and resolve any possible conflict: git pull origin master
  5. Push your edits with git push origin master, when prompted:
    1. Username: git
    2. Password: mypassword
  6. Yes Done You have made your first contribution, congrats!

Advanced

SSH

The more recommended legit way demands your FreeIPA credentials, and you may login to Forgejo to enjoy more fancy features.

There are three places you need to visit, respectively.

FreeIPA Credentials

If you haven't obtain a FreeIPA credential, see FreeIPA Guide and ensure you have the following things ready:

  • FreeIPA Username
  • FreeIPA Password
  • SSH Keys

Forgejo Interface

Screenshot of a verified key on Forgejo
  1. Login to Forgejo with your FreeIPA credentials.
  2. Navigate to SSH / GPG keys, confirm its the same key as in step 2. Forgejo should automatically fetch your SSH Key from FreeIPA.
  3. Verify your SSH key as prompted by the page.

Local Git

Screenshot of a SSH config-ed terminal

Then, we have to re-config your local git client.

  1. Tell git the SSH key name:
    git config core.sshCommand "ssh -i ~/.ssh/your_key_name -o IdentitiesOnly=yes"
  2. Tell git we are going to use SSH:
    git remote set-url origin "ssh://git@192.168.42.170:2222/SAGroup/sysadminrepo.git"
  3. Run git pull origin master to verify everything is working.
  4. Yes Done