Git: Working with Remotes from the Command Line

From Foss2Serve
(Difference between revisions)
Jump to: navigation, search
(Additional Information:)
 
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
{| border="1"
+
 
|-
+
{{Learning Activity Overview
|'''Title''' ||Setting up Git Server
+
|title=
|-   
+
Setting up Git Server
|'''Overview''' ||
+
|overview=
 
Git is an open source distributed version control system originally developed to support the development of the Linux kernel.  
 
Git is an open source distributed version control system originally developed to support the development of the Linux kernel.  
  
Line 10: Line 10:
  
 
Every Git working directory is a full-fledged repository with complete history and full version tracking capabilities, not dependent on network access or a central server.
 
Every Git working directory is a full-fledged repository with complete history and full version tracking capabilities, not dependent on network access or a central server.
 +
|prerequisites=
 +
Version Control/Repository
 +
|objectives=
 +
* Set up Git
 +
|process skills=
 +
}}
  
 +
=== Background ===
  
 
 
 
|-
 
|'''Prerequisite Knowledge''' ||Version Control/Repository
 
 
|-
 
|'''Learning Objectives''' ||Setting up Git   
 
|}
 
 
=== Background: ===
 
 
Version Control:
 
Version Control:
 
A version control system is a repository of files that records the changes to a file or set of files often the files for the source code of computer programs, with monitored access. Every change made to the source is tracked, along with who made the change, why they made it, and references to problems fixed, or enhancements introduced, by the change so that you can recall specific versions later.
 
A version control system is a repository of files that records the changes to a file or set of files often the files for the source code of computer programs, with monitored access. Every change made to the source is tracked, along with who made the change, why they made it, and references to problems fixed, or enhancements introduced, by the change so that you can recall specific versions later.
Line 59: Line 55:
 
More git commands can be found here: https://git-scm.com/docs
 
More git commands can be found here: https://git-scm.com/docs
  
=== Directions: ===
+
=== Directions ===
 +
 
 
'''Installation:'''
 
'''Installation:'''
  
Line 143: Line 140:
 
Also, review the following rubric for generating and submitting your work.  Once you are satisfied that your lab is complete, create a pdf file and name it FossCloneWithGitLab_yourlastnamefirstinitial.pdf. Submit your work as indicated by your instructor (such as submitting into your course management system).
 
Also, review the following rubric for generating and submitting your work.  Once you are satisfied that your lab is complete, create a pdf file and name it FossCloneWithGitLab_yourlastnamefirstinitial.pdf. Submit your work as indicated by your instructor (such as submitting into your course management system).
  
=== Deliverables: ===
+
=== Deliverables ===
Create a document and include screenshots of different stages of installations in it. Make sure all screenshots are accompanied by proper captions and/or brief explanation as necessary. In addition, answer the questions.
+
 
 +
Create a document and include screenshots of different stages of installations in it.  
 +
Make sure all screenshots are accompanied by proper captions and/or brief explanation as necessary.  
 +
In addition, answer the questions.
  
  
Line 158: Line 158:
 
  • Grammar, Spelling and Neatness (5 points) – named file correctly and uploaded properly on time. (5 points)
 
  • Grammar, Spelling and Neatness (5 points) – named file correctly and uploaded properly on time. (5 points)
  
=== Comments: ===
+
=== Comments ===
 
+
=== Additional Information: ===
+
{| border="1"
+
|-
+
|'''Knowledge Area/Knowledge Unit''' || SDF - Software Development Fundamentals, SE - Software Engineering
+
|-
+
|'''Topic''' ||  Git Set up
+
|-
+
|'''Level of Difficulty''' || Medium
+
|-
+
|'''Estimated Time to Completion''' ||2 hours
+
|-
+
|'''Materials/Environment''' ||
+
|-
+
|'''Author''' ||  Mohsen Dorodchi
+
|-
+
|'''Source''' ||
+
|-
+
|'''License''' ||
+
|}
+
 
+
 
+
--------------------
+
  
 +
=== Additional Information ===
 +
{{Learning Activity Info
 +
|acm unit=
 +
SDF - Software Development Fundamentals, SE - Software Engineering
 +
|acm topic=
 +
Git Set up
 +
|difficulty=
 +
medium
 +
|time=
 +
2 hours
 +
|environment=
 +
|author=
 +
Mohsen Dorodchi
 +
|source=
 +
|license=
 +
}}
  
[[Category: Learning_Activity]]
+
[[Category:Learning Activity]]
[[Category: Subcategory:Git Set up]]
+
[[Category:CS2]]
 +
[[Category:Git]]
 +
[[Category:Good Draft]]

Latest revision as of 00:07, 8 September 2018


Title

Setting up Git Server

Overview

Git is an open source distributed version control system originally developed to support the development of the Linux kernel.

Using git clone [url] , you can clone a repository.

Every Git working directory is a full-fledged repository with complete history and full version tracking capabilities, not dependent on network access or a central server.

Prerequisites

Version Control/Repository

Learning
Objectives
After successfully completing this activity, the learner should be able to:
  • Set up Git
Process Skills
Practiced


Background

Version Control: A version control system is a repository of files that records the changes to a file or set of files often the files for the source code of computer programs, with monitored access. Every change made to the source is tracked, along with who made the change, why they made it, and references to problems fixed, or enhancements introduced, by the change so that you can recall specific versions later. In this lab we will be using a git version control system.

Git version control: git is an open source distributed version control system originally developed by Linus Torvalds to support the development of the Linux kernel. Every Git working directory is a full-fledged repository with complete history and full version tracking capabilities, not dependent on network access or a central server. Git can be used as a local version control system without having any central repository.

Some of the basic Git commands are listed here.

Clone: Downloads the project and its entire history.

$ git clone [url]

Branch: Lists/creates new branch

$ git branch [branch-name]

Checkout: Switches between branches / updates working directory.

$ git checkout [branch-name]

Pull: Fetches all the history and merge to working directory.

$ git pull

Push: Uploads all the branch commits to remote URL.

$ git push [alias] [branch]

Commit: commits file snapshots permanently to the version history.

$ git commit –m “Commit message”

More git commands can be found here: https://git-scm.com/docs

Directions

Installation:

The git installation instructions for respective operating system can be found at:

https://git-scm.com/downloads

Below is the command to install git in fedora OS:

$ yum install git

Once git has been installed, all the commands supported by git can be viewed by just typing git at the command line.

Configuration:

The first thing we do after installation is introducing ourselves to git.

git config --global user.email "your Email"
git config --global user.name "Your Name"


Basic git usage:

• Creating a repository:

mkdir GitSetUp
cd GitSetUp
git init

• Cloning a repository:

 git clone git@github.com:phacility/phabricator.git

A repository can be newly created or cloned from other repository.


Now that we created a repository to the client's machine. Now we can create/edit the files, then commit them.

• Creating new file and adding it to git:

touch exampleFile.txt
git status

The file sample.txt is not added to the tracking list of git. So even if we try to commit, this file will not be added to the repository. So to track this file, we add the file to the git stage.

git add exampleFile.txt
git status

Now, the file sample.txt is added to the git stage and it will be tracked for any changes.

• Committing the Changes:

git commit -m "This is the commit message for tracking changes."
git status

• Working with git branches:

git branch

Initially we only have one branch i.e, “master”. We would try to create a new branch named “bugfix_bugid”.

git branch bugfix_bugid
git branch

Now, we will try to create a new file newFile.txt and commit it.

git commit -m "Here are the changes to fix the bug."

The new file commit will only be committed to the branch bugfix_bugid as we are currently working in that branch.

git checkout master
git ls-files
git checkout bugfix_bugid
git ls-files

Using branches, we can create multiple branches for each bugfix and then merge it to the master branch when done.


Documentation:

Create a file in your favorite editor. Add all your screenshots and then answer the following questions in the next section in your file. Also, review the following rubric for generating and submitting your work. Once you are satisfied that your lab is complete, create a pdf file and name it FossCloneWithGitLab_yourlastnamefirstinitial.pdf. Submit your work as indicated by your instructor (such as submitting into your course management system).

Deliverables

Create a document and include screenshots of different stages of installations in it. Make sure all screenshots are accompanied by proper captions and/or brief explanation as necessary. In addition, answer the questions.


Cloning Lab Rubric (100 points)

Screenshots of the above 5 steps (50 points)

Lab Questions (50 points)

•	What is Git Server? (10 points)      
•	Name several free git servers for educational purposes. (10 points)      
•	Explain the importance of version control. (10 points)            
•	What would  the branch and checkout commands do ? (10 points) 
•	Grammar, Spelling and Neatness (5 points) – named file correctly and uploaded properly on time. (5 points)

Comments

Additional Information

ACM BoK
Area & Unit(s)

SDF - Software Development Fundamentals, SE - Software Engineering

ACM BoK
Topic(s)

Git Set up

Difficulty

medium

Estimated Time
to Complete

2 hours

Environment /
Materials
Author(s)

Mohsen Dorodchi

Source
License
Personal tools
Namespaces
Variants
Actions
Events
Learning Resources
HFOSS Projects
Evaluation
Navigation
Toolbox