Using Git under eComStation

From EDM2
Jump to: navigation, search

This is just a quick introduction on how to use git.exe on OS/2 and eComStation. The use of git.exe is the same as in other platforms. My goal was to make a quick tutorial of using git.exe with the GitHub website to clone, commit and push the content.

Introduction

What is git.exe

Git is a distributed version control and source code management (SCM) system with an emphasis on speed [1]. It is something similar to CVS or SUBVERSION (SVN).

What is github.com

GitHub.com is a service on the Web that provides free and public git repository.

  • If you want to host a free, open source and open for the public project it is free of charge.
  • If you want to host a personal, close to the public project, you will have to pay a fee.

GitHub offers the code repository, wikis, issues tracking tools, and it is very easy to fork open source projects. If you are a developer and want to try little changed to an open source project, it just takes you one click to "fork" the project and create a copy of the code on your own GitHub repository.

Bitbucket.org is another similar site on the web with much the same offerings as GitHub and as well as supporting git also supports Mercurial, another SCM with similar usage as git.

Requirements

According to the git RPM installer this are the packaged dependencies.

  • ash
  • ca-certificates
  • cube
  • libc
  • libcurl
  • libgcc444
  • libgcc446
  • openssl
  • os2-base
  • os2-mpts
  • pthread
  • urpo
  • zlib


Installation

If you have RPM/Yum installed you can run:

yum install git

As an alternative there is also this port, [2]. Read the included readme for installation instructions.

First-Time Git Setup

The first step on Git is to set your name and e-mail address. You can do this with on the command promt with:

git config --global user.name "John Doe"
git config --global user.email johndoe@example.com

Some other configuration:

git config --global core.editor "'C:/os2/e.exe' -multiInst -notabbar -nosession -noPlugin"

This changes get stored on the .gitconfig file that is generally stored on "C:\home\xxx\config" directory.

Cloning a repository

Command Line

First locate yourself into the directory where you want to project to be cloned. To clone a git repository from GitHub for example you can do it by the command line:

git clone https://github.com/OS2World/UTIL-WPS-Bubblepad.git

You will get this message:

Cloning into UTIL-WPS-Bubblepad...
remote: Counting objects: 33, done.
remote: Compressing objects: 100% (22/22), done.
remote: Total 33 (delta 9), reused 26 (delta 8)
Unpacking objects: 100% (33/33), done.

This will create a clone of the "UTIL-WPS-Bubblepad" repository on the directory from which you called git.exe.

Checking Changes

If you have modified some files in your local repository copy you can get inside your repository folder and execute:

[D:\git\WPS-Bubblepad]git status

You will get this message of the modified files.

# On branch master
# Your branch is ahead of 'origin/master' by 1 commit. 
# 
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   README.md
#
no changes added to commit (use "git add" and/or "git commit -a")

On this case I had modified only the "README.md" file.

To see your actual changes execute git diff

You will get a unified diff output.

diff --git a/README.md b/README.md
index 172dd6b..7a53b40 100644
--- a/README.md
+++ b/README.md
@@ -17,4 +17,5 @@ AUTHORS

 LINKS
 =============
-* http://www.os2world.com/cdwriting/bubblepad/bubblepadmain.htm
\ No newline at end of file
+* http://www.os2world.com/cdwriting/bubblepad/bubblepadmain.htm
+* https://github.com/OS2World/UTIL-WPS-Bubblepad.git
\ No newline at end of file

At this point you can add an empty line at the end of the file, important if a source file.

Commit

To commit the changed you need to run a command like:

[D:\git\UTIL-WPS-Bubblepad]git commit -a -m 'Changes to Readme'

You will get a message like:

[master 6627f1f] Changes to Readme
 1 files changed, 2 insertions(+), 1 deletions(-)

Format Patch

To format a patch for sending a formatted patch to a project you can use a command like:

[D:\git\UTIL-WPS-Bubblepad]git format-patch -1
0001-Changes-to-Readme.patch

The -1 means to use the last commit, -2 would mean the last 2 commits etc. A file will be in your repository containing the formated patch, in this case,

From 58e1fac763188ed5711fce6b96283e73561b2e4e Mon Sep 17 00:00:00 2001
From: Joe Foo <joe.foo@gmail.com>
Date: Thu, 5 Sep 2013 20:16:05 -0700
Subject: [PATCH] Changes to Readme

---
 README.md |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/README.md b/README.md
index 172dd6b..aceabc5 100644
--- a/README.md
+++ b/README.md
@@ -17,4 +17,5 @@ AUTHORS

 LINKS
 =============
-* http://www.os2world.com/cdwriting/bubblepad/bubblepadmain.htm
\ No newline at end of file
+* http://www.os2world.com/cdwriting/bubblepad/bubblepadmain.htm
+* https://github.com/OS2World/UTIL-WPS-Bubblepad.git
--
1.7.2.3

This can be attached to an email message and sent upstream for review and committing. It is also possible for git to actually send the patch as an email but is beyond this simple tutorial.

Push

Now I want to push the commited changed to the github repository. So inside the project folder I run the following:

[D:\git\UTIL-WPS-Bubblepad]git push

It will quickly ask your github user name and password. Remember that you will need access to the repository you are uploading content. When you type them no input is showed on the command line, don't worry about it, just be sure to type the username and password correctly.

Username:
Password:
Counting objects: 8, done.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 578 bytes, done.
Total 6 (delta 4), reused 0 (delta 0)
   6479ef2..6627f1f  master -> master

Now check your GitHub page. You will see the new file there.

GitHubTest1.png

Adding Files

But what about if you want to add new files instead of just changing something?

So I created a "crapfile.txt" file inside the /WPS-BubblePad directory. After that I executed:

[D:\git\UTIL-WPS-Bubblepad]git add *.*

No message is returned.

After that I did some a commit:

[D:\git\UTIL-WPS-Bubblepad]git commit -a -m 'Crapfile'

The response was:

[master ed6e926] Crapfile
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 crapfile.txt

And the push to upload it to the repository.

[D:\git\UTIL-WPS-Bubblepad]git push

And here it is a similar response for the push:

Username:
Password:
Counting objects: 4, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 296 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
   6627f1f..ed6e926  master -> master

Final Words

This was just a quickly introduction on how to use git.exe with a GitHub site. Of course that Git has a lot of functionality and additional features. Use git help for a quick overview of commands and for additional help use git help COMMAND, eg git help commit.

Errors

No Templates and No "https" helper

[C:\programs\git]git clone https://github.com/OS2World/WPS-Bubblepad.git
warning: /bin/sh is not found. cmd.exe will be used alternatively.
Cloning into WPS-Bubblepad...
warning: templates not found /@unixroot/usr/share/git-core/templates

The "/share/git-core/templates" directory is not in the right location. By default it looks for it on your @unixroot directory. You can edit your file ".gitconfig" and change the path to the correct directory. Just add:

[init]
     templatedir = <path>/share/git-core/templates

No "https" helper

[C:\programs\git]git clone https://github.com/OS2World/WPS-Bubblepad.git
warning: /bin/sh is not found. cmd.exe will be used alternatively.
Cloning into WPS-Bubblepad...
fatal: Unable to find remote helper for 'https'

It seems that some requirement is missing from the git.exe required libraries.

You can also try using the git transport like:

 git clone git://www.github.com/OS2World/UTIL-WPS-Bubblepad.git

Notice that you use git:// instead for https://

error: Terminal is dumb, but EDITOR unset

[D:\git\WPS-Bubblepad]git commit
error: Terminal is dumb, but EDITOR unset
Please supply the message using either -m or -F option.

The editor is not configured on the .gitconfig configuration file.

Links