Initialising a Repository in an Existing Directory
If you wish to have a project directory under version control with GIt, do the following
$ cd /home/user/my_project
$ git init
If you wish to add existing files into the version control
$ git add *.sh
$ git add LICENSE
$ git commit --m "Gekko Menu Help Application"
[master (root-commit) c98ae91] Gekko Menu Help Application
1 file changed, 73 insertions(+)
create mode 100755 mymenu.sh
You have an initial commit and tracked files. Hooray.
Checking the status of your Files
[user1@node1 menu]$ git status
# On branch master
nothing to commit, working directory clean
This means you have a clean working directory; in other words, none of your tracked files are modified.
Adding new files to your Git Directory
Let’s say you added a new file called check_license_abaqus.sh into the Project Directory, you will have something like
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# check_license_abaqus.sh
nothing added to commit but untracked files present (use "git add" to track)
To add files
[user1@node1 menu]$ git add check_license_abaqus.sh
[user1@node1 menu]$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: check_license_abaqus.sh
#
To remove file
[user1@node1 menu]$ git rm check_license_abaqus.sh -f
rm 'check_license_abaqus.sh'
[user1@node1 menu]$ git status
# On branch master
nothing to commit, working directory clean
To see log, you want to use the command
[user1@node1 menu]$ git log
commit xxxxxxxxx
Author: user1 <kmyemail_used_in_Github@hotmail.com>
Date: Sun Sep 25 23:50:33 2022 +0800
Gekko Menu Help Application
GitHub is the largest code-hosting platform in the world. It uses Git as version control and the repository is based on GitHub. Features such as Pull Requests, Project Boards and GitHub are central and found in one place.
On Linux, you can generate your SSH key using the email that you have created in your GitHub User Account
[user1@node1 ~]$ ssh-keygen -t rsa -C "myemail_used_in_Github@hotmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user1/.ssh/id_rsa):
/home/user1/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user1/.ssh/id_rsa.
Your public key has been saved in /home/user1/.ssh/id_rsa.pub.
The key fingerprint is:
........
........
Adding the SSH Key to the ssh-agent
Although this is not mandatory, adding the SSH Key to the SSH Agent is a good practice that will keep the SSH Key safe. The SSH-agent is an SSH Key Manager that helps to keep the SSH key safe because it protects your SSH keys from being exported. The SSH Agent also saves you from having to type the passphrase you create. every time your SSH key is used.
Before you check, you want to check your ~/.ssh/config first
$ vim ~/.ssh/config
Host *
AddKeysToAgent yes
At the Terminal,
$ ssh-add ~/.ssh/id_rsa
Copy your SSH Public Key to the field. In your ~/.ssh/config, it should have a .pub extension like id_rsa.pub
Configuring Git
To intialise the Git. Do the following. You may want to take a look at