git Programming

git – cli – part 1

Reading Time: 2 minutes

GIT is a version and control system. We will discuss creating a GIT repository and some of the other features that are useful about it. Most end users or admins might only care about installing a .DEB package or using YUM to install an .RPM. It is also hard some times to escape downloading; configuring; compiling; and installing from source. Git is one of the more popular methods for that. But is also capable of much much more. In this segment we are going to discuss git as a cli. There is also a GUI manager.

#:/home/user# mkdir hello-world
#:/home/user# cd hello-world
#:/home/user/hello-world# git init
Initialized empty Git repository in /home/user/hello-world/.git/
#:/home/user/hello-world#

When you look in this directory. you will see a directory that’s marked .git and inside there are a number of components that make up the “git” archive.

Let’s create 2 files for our project. Let’s start with a hello-world.c and a Makefile

#include <stdio.h>

int main (void)
{
  printf("Hello World!\n");
}
hello-world: hello-world.c
        gcc hello-world.c -o hello-world

Let’s add these files to the project.

git add hello-world.c
git add Makefile

Committing: now that we have a project let’s commit the files to our project.

git commit -m "Initial Commit"

The first time you do this you may see something like

#: git commit -m "Initial Commit"

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'root@node3.(none)')

Now this is a case where I couldn’t or didn’t want to see the forest for the trees. So I am going to go slow on this to remind me. I will assume you that in explaining this – it will be rendered obvious for all time. As part of the “.git” repository there is a little house cleaning we need to perform. We need to set some initial values as one might expect.

config: Setting the Username:

#: git config --global  user.name "John Doe"

For my benefit. Think of “user.name” as a field to be set. So when you set this value leave the field as literally “user.name”. The “John Doe” bit DOES get changed.

#: git push origin master:refs/heads/master

Related posts

CORE STUDY: Gogs

Tom Hamilton

Apple URL for emulation and programming

user

Python PIP

Tom Hamilton