Orientation to Computing-I (Lovely Professional University) PDF
Document Details
Uploaded by CommodiousParable
Lovely Professional University
Tags
Summary
This document provides an orientation to computing, specifically focusing on the use of Git and GitHub for version control. It covers a range of Git commands and workflows suitable for computer science students.
Full Transcript
Orientation to Computing-I L T P :2 0 0 www.lpu.in Lovely Professional University 1 Unit-6 (Version Control) Overview of Git and Github Install git and Create a GitHub account Create a local g...
Orientation to Computing-I L T P :2 0 0 www.lpu.in Lovely Professional University 1 Unit-6 (Version Control) Overview of Git and Github Install git and Create a GitHub account Create a local git repository Add a new file to the repository Creating a commit Creation of a new branch Git Commands www.lpu.in Lovely Professional University 2 What is Git and GitHub? Git: Git is a distributed version control system for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. Its goals include speed, data integrity, and support for distributed, non-linear workflows. GitHub: GitHub is a web-based Git repository hosting service, which offers all of the distributed revision control and source code management (SCM) functionality of Git as well as adding its own features. www.lpu.in Lovely Professional University 3 Diff. between Git and GitHub? www.lpu.in Lovely Professional University 4 Diff. between Git and GitHub? www.lpu.in Lovely Professional University 5 Install Git https://git-scm.com/downloads www.lpu.in Lovely Professional University 6 Create GitHub Account https://github.com/ www.lpu.in Lovely Professional University 7 Create a local git repository Start a new git repository Create a directory to contain the project. Go into the new directory. Type git init. Write some code. Type git add to add the files (see the typical use page). Type git commit. www.lpu.in Lovely Professional University 8 Add a new file to the repository Create your new files or edit existing files in your local project directory. Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed. www.lpu.in Lovely Professional University 9 Creating a Commit www.lpu.in Lovely Professional University 10 Creation of a new branch The git branch command can be used to create a new branch. When you want to start a new feature, you create a new branch off main using git branch new_branch. Once created you can then use git checkout new_branch to switch to that branch. www.lpu.in Lovely Professional University 11 Git Commands Learn the concept of controlling, forking, building repositories Git Commands Introduce yourself to Git $ git config --global user.name {given name} $ git config --global user.email {given email} Git Commands Run your code editor $ code. Git Commands Intialize empty Git repository $ git init Git Commands Adding the work to staging area $ git add {filename} Git Commands Commiting from stage to final $ git commit Git Commands add new file to repository $ touch {file name} Git Commands If you want all files to be added to staging area $ git add -A Git Commands Adding comments while inserting commits $ git commit -m "your comment" Git Commands Undo the work done by mistake in staging area from a file $ git checkout {filename} Git Commands Recovery for multiple files altogether $ git checkout -f Git Commands Check for complete logs $ git log Check for complete logs but with numbered steps $ git log -p -{mention no of steps} Git Commands To check for changes in file $ git diff Git Commands Auto commit all files in staging area $ git commit -a -m "Comment" Git Commands Removing files $ git rm {filename} Git Commands Branching into repository $ git branch {branch name} Switching to new branch $ git checkout {branchname}