Week 2 Git - DevOps Implementation PDF

Document Details

PropitiousSacramento8477

Uploaded by PropitiousSacramento8477

Centennial College

2025

Yin Hua Li

Tags

Git version control DevOps software development

Summary

This document is a presentation about DevOps implementation, specifically focusing on version control with Git. It covers different types of version control systems (VCS) and key Git commands. The presentation is from Centennial College, for week 2 of the 2025 winter semester.

Full Transcript

DevOps Implementation Yin Hua Li Centennial College Week#2 2025 Winter Topic: Version Control with Git 1 ¡ Version Control Systems (VCS) ¡ Git fundamentals 2 ¡ Version control is about the manag...

DevOps Implementation Yin Hua Li Centennial College Week#2 2025 Winter Topic: Version Control with Git 1 ¡ Version Control Systems (VCS) ¡ Git fundamentals 2 ¡ Version control is about the management of multiple versions of a project § Each change (e.g., addition, edition, or removal) to the files in a project must be tracked § Each change made a file (or a group of files) can be undone or roll back § The tool to do version control is called Version Control System 3 ¡ Local Version Control System § Track the changes made to files in a single database that was stored locally § Supporting team work was out of the question § Source Code Control System(SCCS) was developed by AT&T, and was very popular in 1970s ¡ Centralized Version Control System § Store the change history on a single server that the clients (authors) can connect to § Support team work § The main issue is that once a file is being used by someone, then the file is locked and other team members cannot work on it ¡ Distributed Version Control System § Very similar with centralized VCS with a big difference: no main server that holds all the history § Each client has a clone of the repository § The concept of “forking” is to allow each team member to clone a repository and make changes to the project, it also enable team member pull changes from other repository if he/she sees fit § It is faster than other types of VCS 4 Source: https://thedailywtf.com/articles/Source-Control-Done-Right 5 Centralized Version Control Distributed Version Control Needs a network connection (Mostly) does not need a network connection Add, edit, delete, check in/out, branch, Add, edit, delete, check in, branch, merge, merge undo available offline The server knows what’s on your machine Remote server is completely unaware until you “push” 6 ¡ Created by Linus Torvalds in 2005 to replace BitKeeper to manage Linux kernel changes ¡ Distributed version control system ¡ Command line version control system ¡ Uses checksums to ensure data integrity ¡ Cross-platform, open source , free ¡ Download from https://git-scm.com/download/ Source: https://git-scm.com/ 7 Source: https://openhub.net/repositories/compare/ 8 ¡ Download from https://git-scm.com/downloads ¡ Install § select default editor for Git 9 git clone ¡ A repository is a storage where the project and all the changes made to it are kept § For each project that you want to manage with Git, you have to set up a repository for it § git init / git clone ¡ Working Directory § Each file you work on is on the working area § Never modify the files inside “.git” directory ¡ Staging area (Index) is where your files go before the snapshots are taken ¡ Commit is a snapshot of the entire project at a certain time ¡ There is a situation when you are on the way to do your work (working on a branch), the work has not finished and not ready to commit yet; however now you need to work on something else, and come back to your previous work later. In this case, you can temporarily store the changes you've made to your working copy. The area storing your current work is called Stash 10 Stash ¡ Let’s first focus on Working directory, Index and Repository § The commands moving data from left to right ▪ git add ▪ git commit § The commands moving data from right to left ▪ git checkout ▪ git restore –staged ▪ git rm --cached // unstage, the content in working area is left alone § Git diff command ▪ git diff // compare the content in working area and index area ▪ git diff --cached “commit name” ▪ git diff commit1 commit2 11 Source:https://uidaholib.github.io/get-git/3workflow.html 12 13 ¡ Check commit log is one of the most often used feature of Git 14 ¡ Show and learn what changes have been made to a particular commit § Git show ▪ Name is the first 7 letters 15 ¡ git revert reverts some existing commits, A revert operation will take the specified commit, inverse the changes from that commit, and create a new "revert commit" 16 ¡ git reset command is used to undo the changes in your working directory and get back to a specific commit while discarding all the commits made after that one. § git reset [] [] : resets the current branch head to and possibly updates the index and the working area depending on. If is omitted, defaults to --mixed. The must be one of the following: ▪ --soft Does not touch the index file or the working tree at all (but resets the head to , just like all modes do). This leaves all your changed files "Changes to be committed", as git status would put it. ▪ --mixed Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated. This is the default action. ▪ --hard Resets the index and working tree. Any changes to tracked files in the working tree since are discarded. Any untracked files or directories in the way of writing any tracked files are simply deleted. 17 Source: https://www.scmgalaxy.com/tutorials/git-commands-tutorials-and-example-git-reset-git-revert/ ¡ Git checkout b ¡ Git reset b 18 Stash Git stash Git stash apply ¡ Use following command to manage stash area § git stash –include-untracked | --keep-index | -u | –all | -patch § git stash ls § git stash apply § git stash clear 19 ¡ Ignore file(s): specified file(s) (e.g., personal configs, passwords, compiled outputs, temporary files, logs, etc.), files matching a description, and directories left untracked § Listed in.gitignore file which should be placed at the root of your repository §.gitignore file is tracked and versioned 20 ¡.gitignore file can include not only specific file but also directories and files matching a description ¡ A collection of.gitignore templates can be found at https://github.com/github/giti gnore 21 ¡ Each commit must be independent, atomic and complete § Never commit a project that is half-done § Split a big task into several logic chunks, and each chunk makes sense itself § A commit is to introduce a feature or fix a bug ¡ Commit message is to explain why those changes were made § Commit messages should be consistent, clear and contextualized ▪ No longer than 50 characters ▪ Use present form rather than past tense ▪ Begin with a capital letter ▪ Don’t end message with a period 22 ¡ https://medium.com/devopscurry/understanding-version-control-in-devops-in-a-simple-way-5b8a5a2aab4c ¡ https://www.slideshare.net/bcbbslides/introduction-to-git-and-github-72514916 ¡ https://dzone.com/articles/top-20-git-commands-with-examples ¡ https://www.datacamp.com/tutorial/git-reset-revert-tutorial 23

Use Quizgecko on...
Browser
Browser