What is Git Hub - Github Basics PDF

Title What is Git Hub - Github Basics
Course Web Design &Applications
Institution University of Mumbai
Pages 4
File Size 121 KB
File Type PDF
Total Downloads 89
Total Views 148

Summary

Github Basics...


Description

What is GitHub? 1. Web based, GitHub is a web based Git Repository with web interface hosting service. It is a command line based tools. 2. Origin, GitHub was launched in April, 2008. 3. Subscription, GitHub offers both private repository and Free accounts which are usually used to host open source software and projects. 4. User needs to open an account in order to contribute to the site but public repository can be browsed and downloaded by anyone. 5. Other feature includes documentation, bug tracking, issue tracking, Wiki feature, etc. 6. It is the largest source of source code in the world. 7. GitHub provides both personal as well as business use. 8. Signup to GitHub from www.github.com Another Technique for creating Git Repository on GitHub Clone from GitHub i.e Copying a Git Repository from GitHub to our local machine using clone command. In another word Cloning a GitHub repository(remote) is basically downloading a code base (in the remote repository) to your own machine(local), so that you can make your own contribution to the code base. What is fork and How to do It in GitHub Forking means creating a new project based on another project that already exist. It is a feature that vastly encourage project advancement and collaboration. To contribute to a new project we can fork the repository and make the changes and release the revise project as a new project. If the original repository that we fork to create our new project gets updated we can easily adds those updates on our current fork. Let’s do it practically: 1. Firstly, google search “sample github project”. 2. Click on the first link which will be https://github.com/skeeto/sample-java-project. 3. To fork, Just click on the fork button and the project gets forked you can observe the changes in url. Copying a GitHub Repository In this section we will clone the project in our local repository, 1. 2. 3. 4. 5.

Copy the url to clipboard. Open the bash terminsl(Git) Firstly check your current position using pwd Change the directory using cd git-fast Now we will clone the repository that we earlier copied in step 1, run the following command git clone https://github.com/skeeto/sample-java-project 6. To check the output of step 5 run ls -l 7. Change the directory to the project using cd sample-java-project we can observe a master written in the bash terminal which is nothing but a separate line of development. 8. And now let’s list the content of the sample java project using ls -al Resource from Site:

Copyi ngaGi t Hubr eposi t or y $cd $gi tc l oneht t ps : / / gi t hub. com/ /

$cdex ampl e_pr oj ec t $l sal Commi t t i ngchangesi nGi t

There are basically 3 steps that every artefact must go-through, 1. Modified, Here we make modification to the repository. Once the file is created we need to modify the file. 2. Staged, Here we add changes to staging area. After modification we need to prepare the file for committing. Here we mark the file as staged using the Git add command. In other word we add the artefact to the index 3. Committed, Here we commit changes to Git database. Once the artefact is staged we finally need to commit it so that git safely stores it in the database and adds it to the commit history. We achieve this using git commit command. Adding your changes to git repository 1. 2. 3. 4. 5.

6. 7.

8. 9.

Open the bash Terminal Run pwd you must be in git-fast Use ls to check the content of this directory. Change the directory to cd myRepoFromScratch/ Create a file using vi command vi demoFile1 we will enter the file Press I key to insert content and add something like we are soon going to demonstrate the use of add command and then press Esc : wq To check the content of the file run cat demoFile1 Lets First understand git status command. This gives us the status of the working directory and the staging area. An untracked files means the file is not tracked by git. Git starts tracking a file once you issue the add command. Run Git add demoFile1 and now check the status using the git status command. To unstage the file run git rm –cached demoFile1 and now again run git status command. After unstaging git no more track the file.

Committing your changes to git repository 1. Check where are you in the terminal using pwd command you must be in myRepoFromScratch 2. Run git status to check the status of the working directory. 3. To stage our changes run git add demoFile1 and check the status using git status 4. Now lets use commit command, run git commit -m “our first commit in this course” m stands for message which help us to track the use of commit. Every commit is added by the commit id. And now again check the status of working directory using git status which will show nothing to commit on branch master. Resource from site Addi ngyourchanges

#homedi r ect or y $pwd $cdgi t f ast $l s $cdmyRepoFr omSc r at ch $l s #cr eat eafi l eandaddsomecont ent $videmoFi l e1 $catdemoFi l e1 $gi tst at us $gi tadddemoFi l e1 $gi tr mcac heddemoFi l e1 $gi tst at us

Commi t t i ngchanges #homedi r ect or y $pwd $gi tst at us $gi tadddemofi l e1 $gi tst at us $gi tcommi tm" ourfi r stcommi ti nt hi scour s e" $gi tst at us

CommandSummar y-addandcommi t $gi tadd $gi tcommi tm" messagegoesher e"

I nspect i ngwhati sgoi ngoni nGi tReposi t or y Thi scanbeachi ev edbyi s sui ngt hef ol l owi ngcommands 1.Gi tst at us,t hi scommandt el l suss t at usoft hewor ki ngdi r ect or yandt hes t agi ngar ea andwhatt hatar enotbei ngt r ack edbyGi t . 2.Gi tl og,wi t ht hi swecanpeeki nt ot hehi st or yofcommi t si not herwor dspr oj ect hi st or yi sdi spl ay edusi ngt hi sc ommand. How t oCheckSt at usi nGi tReposi t or y 1.Opent hebasht er mi nal . 2.Checkt hec ur r entwor ki ngdi r ect or yusi ngpwd. 3.Changet hedi r ect or yus i ngcdgi t f ast / myRepoFr omSc r at c h/. 4.Let ’ sI nspectt hecont entoft hedi r ect or yusi ngl sl. 5.Nowi s suegi tst at uscommand. 6.Nowcr eat ef ewfil esusi ngvi wei ght Los sChar tpr essIandi nser t“ Iwantt osheed 15k gi n5week . . ”andhi tEsc:wq

7.Cr eat eanot herfi l eusi ngvi di et Char tpr essIandi nser t“ Iwantt oaddmor egr een v eget abl et omydi et ”andhi tEsc:wq. 8.I ss uet hegi ts t at uscommand andagai nr ungi tst at us–l ongbot hr esul t sar es ame whi c hmeansgi tst at us–l ongi sact ual l yt hedef aul tbehavi our . 9.Rungi tst at usswher esmeanss hor tr esul twi l lgi v el i s twi t h??meani ngnott r ack ed bygi t . 10.Nowl et ’ sr ungi taddwei ght Los sChar tandagai ni ss uet hegi ts t at usswecans eea Abef or efi l ewhi c hmeansfi l ehasbeenadded. t 11.NowLet ’ scommi tt hefi l eus i nggi tcommi t–ms“ 1 commi tf orwei ght l os sc har t ”. 12.Agai nr ungi ts t at uss. 13.Letusnowmak esomechangest ofi l ewei ght l os sc har tusi ngvi wei ght l oss char tand pr essIandaddcont entl i k es omemor econt ent1andpr es sEsc:wq. 14.Agai nRungi tst at ussnowt hefi l ewi l lbeass i gnedwi t hs t at usM wher eM st andsf or Modi fiedcas e. 15.Addt hefi l et os t agi ngar ea,gi taddwei ght Los sc har tandagai nr ungi tst at usst he wi l lbes t i l l i naM i . e.modi fieds t at e.Gr eencol ori ndi cat efi l ehasbeenaddedt o t aggi ngar ea. 16.Andcommi ti tus i nggi tcommi t–m “ 2ndcommi tf orwei ght l os sc har t ”andagai nr ungi t s t at uss . 17.Nowl et ’ smodi f yt hefil enameofwei ght l oss c har tmvwei ght l oss char t at us wei ght l os sc har t 2 andagai nr ungi tst at usswewi l l findwei ght l os sc har twi t hDst whi c hs t andsf ordel et edandot herfi l eswei ght l os sc har t 2anddi et c har tr emai nsi n unass i gneds t at us . How to check commit history in git repository 1. Open the Bash Terminal. 2....


Similar Free PDFs