[go: up one dir, main page]

0% found this document useful (0 votes)
88 views4 pages

What Is GitHub

Git is a version control system that allows users to track changes to files and collaborate on projects. GitHub is a web-based hosting service for Git repositories that provides additional features like documentation, issue tracking, and wikis. The document discusses various Git and GitHub concepts and commands including cloning repositories, forking projects, adding and committing changes, and inspecting the repository history. Key steps outlined include cloning a remote repository to local machine, forking a project to make contributions, using commands like git add, commit, status, and log to manage changes and view the commit history.

Uploaded by

abirje0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views4 pages

What Is GitHub

Git is a version control system that allows users to track changes to files and collaborate on projects. GitHub is a web-based hosting service for Git repositories that provides additional features like documentation, issue tracking, and wikis. The document discusses various Git and GitHub concepts and commands including cloning repositories, forking projects, adding and committing changes, and inspecting the repository history. Key steps outlined include cloning a remote repository to local machine, forking a project to make contributions, using commands like git add, commit, status, and log to manage changes and view the commit history.

Uploaded by

abirje0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

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. Copy the url to clipboard.


2. Open the bash terminsl(Git)
3. Firstly check your current position using pwd
4. Change the directory using cd git-fast
5. 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:


Copying a GitHub repository

$ cd <project_directory>
$ git clone https://github.com/<user>/<example_project> 
$ cd example_project
$ ls -al 

Committing changes in Git

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. Open the bash Terminal


2. Run pwd you must be in git-fast
3. Use ls to check the content of this directory.
4. Change the directory to cd myRepoFromScratch/
5. 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
6. To check the content of the file run cat demoFile1
7. 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.
8. Run Git add demoFile1 and now check the status using the git status command.
9. 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


Adding your changes
# home directory
$ pwd                          
$ cd git-fast
$ ls
$ cd myRepoFromScratch
$ ls

# create a file and add some content


$ vi demoFile1                    
$ cat demoFile1
$ git status
$ git add demoFile1
$ git rm --cached demoFile1
$ git status

Committing changes

 # home directory
$ pwd                              
$ git status
$ git add demofile1
$ git status
$ git commit -m "our first commit in this course"
$ git status

Command Summary - add and commit

$ git add
$ git commit -m "message goes here"

Inspecting what is going on in Git Repository

This can be achieved by issuing the following commands

1. Git status, this command tells us status of the working directory and the staging area
and what that are not being tracked by Git.
2. Git log, with this we can peek into the history of commits in other words project
history is displayed using this command.

How to Check Status in Git Repository

1. Open the bash terminal.


2. Check the current working directory using pwd.
3. Change the directory using cd git-fast/myRepoFromScratch/ .
4. Let’s Inspect the content of the directory using ls-l .
5. Now issue git status command.
6. Now create few files using vi weightLossChart press I and insert “I want to sheed
15kg in 5 week..” and hit Esc : wq
7. Create another file using vi dietChart press I and insert “I want to add more green
vegetable to my diet” and hit Esc : wq.
8. Issue the git status command and again run git status –long both results are same
which means git status –long is actually the default behaviour.
9. Run git status -s where s means short result will give list with ?? meaning not tracked
by git.
10. Now let’s run git add weightLossChart and again issue the git status -s we can see a
A before file which means file has been added.
11. Now Let’s commit the file using git commit –m “1st commit for weightlosschart” .
12. Again run git status -s .
13. Let us now make some changes to file weightlosschart using vi weightlosschart and
press I and add content like some more content 1 and press Esc : wq.
14. Again Run git status -s now the file will be assigned with status M where M stands for
Modified case.
15. Add the file to staging area, git add weightLosschart and again run git status -s the
will be still in a M i.e. modified state. Green color indicate file has been added to
tagging area.
16. And commit it using git commit –m “2nd commit for weightlosschart” and again run git
status -s.
17. Now let’s modify the file name of weightlosschart mv weightlosschart
weightlosschart2 and again run git status -s we will find weightlosschart with D
status which stands for deleted and other files weightlosschart2 and dietchart
remains in unassigned status.

How to check commit history in git repository

1. Open the Bash Terminal.


2.

You might also like