Programming

Git 101

Download URL: https://git-scm.com/download/win
Install git for windows and launch Git bash. It treats Windows file system as Linux, hence path separator “\” turns into “/”.
Go to your Git repository, click on “Clone or Download” and copy the Clone URL.
GitCloneUrl
Go to your source directory in Git bash prompt

$ cd /c/Dev/source/mcu-india
achindra@TURINGMACHINE MINGW64 /c/Dev/Source/mcu-india
$ git clone https://github.com/mcu-india/CPL.git
Cloning into 'CPL'...
remote: Counting objects: 10, done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 10 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (10/10), done.

Then create a folder for yourself as “Basics/achindra_mca_2005” in CPL for basic of C.
In this directory create a ReadMe file and put in your name, email and your batch. I used nano editor, you can use something else.

/c/Dev/Source/mcu-india/CPL/Basics/achindra_mca_2005
$ nano README.md

To be able to save this file in repository, you should add it to tracking

/c/Dev/Source/mcu-india/CPL/Basics/achindra_mca_2005 (master)
$ git add README.md
warning: LF will be replaced by CRLF in Basics/achindra_mca_2005/README.md.
The file will have its original line endings in your working directory.

Create directory for Assignment 1 and in that directory, write your first program, the customary Hello World!
Add it too to tracking.

$ git add Hello.c

git status command will tell you what files are being tracked and which one’s are excluded. You don’t need to check-in your exe and obj files.

$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)
        new file:   Hello.c
        new file:   ../README.md
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Hello.exe
        Hello.obj

 
Until you run “git commit”, changes are not actually recorded. Git commit will ask you to add a message that explains what changes are being made. This is recorded as part of history.

$ git commit
[master 9a0e7e0] This is Assignment 1. Customary Hello World program.
2 files changed, 24 insertions(+)
create mode 100644 Basics/achindra_mca_2005/Assignment1/Hello.c
create mode 100644 Basics/achindra_mca_2005/README.md

GitCommit.JPG
Final step! “git push”

$ git push
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 2 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (7/7), 803 bytes | 133.00 KiB/s, done.
Total 7 (delta 0), reused 0 (delta 0)
To https://github.com/mcu-india/CPL.git
e1e6b81..9a0e7e0 master -> master

You should now see your changes in the repository.
 

I am a curious mind, always building and experimenting, trying things to decode their inner design. Kind of a small scale inventor ;-) I like to help people realise their passion.

Leave a Reply

Your email address will not be published. Required fields are marked *