Git: Working with Remotes from the Command Line
Setting up Git Server
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.
|After successfully completing this activity, the learner should be able to:
| Process Skills
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
The git installation instructions for respective operating system can be found at:
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.
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 firstname.lastname@example.org: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:
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.
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).
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)
| ACM BoK
Area & Unit(s)
SDF - Software Development Fundamentals, SE - Software Engineering
| ACM BoK
Git Set up
| Environment /