Jump Start Git
()
About this ebook
Get a Jump Start on version control with Git today!
If you've worked on a web development project of any size, you've probably used Git, the most broadly adopted distributed version control system available. It enables you to store different versions of project files and directories, so you can roll back to an earlier one if something goes wrong. And since it's distributed, it smoothes the path for dev team collaboration.
This short, practical book will help you to:
- Understand Git's core philosophy.
- Get started with Git: install it, learn the basic commands, and set up your first project.
- Work with Git as part of a collaborative team.
- Use Git's debugging tools for maximum debug efficiency.
- Master Git workflow
- Take control with Git's advanced features: reflog, rebase, stash, and more.
- Use Git with cloud-based Git repository host services like Github and Bitbucket.
- See how Git's used effectively on large open-source projects.
Whether you're a Git newbie or you've been using it for some time but only really scratching the surface of its capabilities, this book will help you to gain a deep understanding of how Git works, and how to use it to streamline your workflow.
Shaumik Daityari
Shaumik is a data analyst by day, and a comic book enthusiast by night (or maybe, he's Batman?) Shaumik has been writing tutorials and creating screencasts for over five years. When not working, he's busy automating mundane daily tasks through meticulously written scripts!
Related to Jump Start Git
Related ebooks
Jump Start Vue.js Rating: 4 out of 5 stars4/5Learn Programming by Coding Like a Professional: Create Games, Apps, & Programs Rating: 0 out of 5 stars0 ratingsYour First Week With Node.js Rating: 0 out of 5 stars0 ratingsExtending Jenkins Rating: 0 out of 5 stars0 ratingsVisual Studio Code: End-to-End Editing and Debugging Tools for Web Developers Rating: 0 out of 5 stars0 ratingsSql : The Ultimate Beginner to Advanced Guide To Master SQL Quickly with Step-by-Step Practical Examples Rating: 0 out of 5 stars0 ratingsWhere to Place My Project: Code Hosting Platforms Rating: 0 out of 5 stars0 ratingsNode.js: Novice to Ninja Rating: 0 out of 5 stars0 ratingsSvelte: A Beginner's Guide Rating: 0 out of 5 stars0 ratingsLinux, Apache, MySQL, PHP Performance End to End Rating: 5 out of 5 stars5/5Jump Start MySQL: Master the Database That Powers the Web Rating: 0 out of 5 stars0 ratingsJump Start PHP Environment: Master the World's Most Popular Language Rating: 0 out of 5 stars0 ratingsA Guide To All Programming and Coding Languages Rating: 0 out of 5 stars0 ratingsJavaScript: Novice to Ninja Rating: 2 out of 5 stars2/5Node.js: Tools & Skills Rating: 0 out of 5 stars0 ratingsjQuery: Novice to Ninja: Novice to Ninja Rating: 4 out of 5 stars4/5CSS Master Rating: 0 out of 5 stars0 ratingsJump Start Sass: Get Up to Speed With Sass in a Weekend Rating: 0 out of 5 stars0 ratingsElements of Android Room Rating: 0 out of 5 stars0 ratingsJavaScript: Best Practice Rating: 0 out of 5 stars0 ratingsBeginning Database Design Solutions: Understanding and Implementing Database Design Concepts for the Cloud and Beyond Rating: 0 out of 5 stars0 ratingsShell Scripting: Expert Recipes for Linux, Bash, and more Rating: 0 out of 5 stars0 ratingsProfitable Programming: Unlocking Success in the Digital Age Rating: 0 out of 5 stars0 ratingsAngularJS Deployment Essentials Rating: 0 out of 5 stars0 ratingsMicrosoft .NET Framework 4.5 Quickstart Cookbook Rating: 0 out of 5 stars0 ratingsExploring Android Rating: 0 out of 5 stars0 ratingsOpenCV Android Programming By Example Rating: 0 out of 5 stars0 ratingsSimply SQL: The Fun and Easy Way to Learn Best-Practice SQL Rating: 4 out of 5 stars4/5
Software Development & Engineering For You
Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5How to Build and Design a Website using WordPress : A Step-by-Step Guide with Screenshots Rating: 0 out of 5 stars0 ratingsBeginning Programming For Dummies Rating: 4 out of 5 stars4/5Case Studies in Design Patterns Rating: 5 out of 5 stars5/5Python For Dummies Rating: 4 out of 5 stars4/530 Days to DevOps Proficiency Rating: 0 out of 5 stars0 ratingsHow Do I Do That In InDesign? Rating: 5 out of 5 stars5/5UX Simplified: Models & Methodologies Rating: 3 out of 5 stars3/5Ace the Trading Systems Developer Interview (C++ Edition) : Insider's Guide to Top Tech Jobs in Finance Rating: 5 out of 5 stars5/5PYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5How to Start a Business Analyst Career Rating: 5 out of 5 stars5/5Grokking Simplicity: Taming complex software with functional thinking Rating: 4 out of 5 stars4/5ITIL 4: Digital and IT strategy: Reference and study guide Rating: 5 out of 5 stars5/5Hands-On Python for DevOps: Leverage Python's native libraries to streamline your workflow and save time with automation Rating: 0 out of 5 stars0 ratingsWordpress 2023 A Beginners Guide : Design Your Own Website With WordPress 2023 Rating: 0 out of 5 stars0 ratingsOperations Anti-Patterns, DevOps Solutions Rating: 0 out of 5 stars0 ratingsAngular in Action Rating: 0 out of 5 stars0 ratingsLean Management for Beginners: Fundamentals of Lean Management for Small and Medium-Sized Enterprises - With many Practical Examples Rating: 0 out of 5 stars0 ratingsGit Essentials Rating: 4 out of 5 stars4/5UML Demystified Rating: 0 out of 5 stars0 ratingsRy's Git Tutorial Rating: 0 out of 5 stars0 ratings3D Tutorials Collection Rating: 0 out of 5 stars0 ratingsFundamentals of Software Engineering: Designed to provide an insight into the software engineering concepts Rating: 0 out of 5 stars0 ratingsGood Code, Bad Code: Think like a software engineer Rating: 5 out of 5 stars5/5Fast Python: High performance techniques for large datasets Rating: 0 out of 5 stars0 ratingsThe Practice of Enterprise Architecture: A Modern Approach to Business and IT Alignment Rating: 4 out of 5 stars4/5The Creative Programmer Rating: 0 out of 5 stars0 ratings
Reviews for Jump Start Git
0 ratings0 reviews
Book preview
Jump Start Git - Shaumik Daityari
Chapter 1: Introduction
Chapter
Introduction
In my freshman year in college, I started work on my first intranet application. The files in the main directory of the partially functioning application looked something like Figure 1-1.
The directory structure of my first web application titled “Online Exams”Looking at the file names in this directory, you can see that I used some very similar names, such as exam.php, exam1.php and examfile.php. The purpose of that naming convention was to create new versions of my application without losing the old, working logic—in case the new ideas failed! I assumed that, because I understood what each of those files did, it should be fine to have a bunch of similarly named files.
However, there were two flaws in that thinking. Firstly, anyone else examining this code wouldn’t be able to make sense of this mess. Secondly, after a few months, even I was struggling to recall what each version of these files was for. Clearly, I needed a better system for managing the various versions of my files.
If I had this much trouble working on a small, personal project, imagine how difficult it must have been for larger software projects, with thousands of files and contributors distributed all over the world! Developers once used emails to coordinate changes among team members. When they made changes to a project, they would each create a diff
file with all their changes and email it to the lead developer, who would incorporate them into the project if everything worked properly.
When you’re working on the same files as other developers, keeping track of what you’ve changed and trying to merge it with work done by your peers becomes very difficult. It can result in a lot of confusion and time wasting.
Imagine another situation, where you’re working on an idea and your boss wants to see what you’ve already completed. Ideally, you’d want to be able to do the following:
stash away the changes and revert to the last stable state
show your boss the latest completed work
resume your work with the current state once that’s done
All of the situations I’ve described above give rise to the need for what’s known as version control
. So let’s find out what that is.
Version Control
Version control (or revision control) is a system that records changes to a file or a group of files and directories over time, so that you can review or go back to specific versions later. Over the course of this book, I’ll demonstrate how this works. But first, let’s examine in more detail what version control is.
Quite literally, version control means maintaining versions of your work—perhaps most commonly in the form of source code, though it can be used for other kinds of work too. You may like to think of version control as a tool that takes snapshots of your work across time, creating checkpoints. You can return to those checkpoints any time you want. Not only are the changes recorded in these checkpoints, but also information about who made the changes, when they made them, and the reasons behind the changes.
I’ve already mentioned the first objective of version control—to back up and restore. Version control eliminates the need to create backup files like I was doing in my college days (that is, endless duplicates with different names). Version control also gives you the ability to return to previous states of your work without losing the current state.
Version Control Doesn’t Replace the Need for a Regular Backup Solution
The word backup
above, as noted, refers to the process of creating multiple copies of the same file. Git removes the need for that. However, this is different from regularly backing up your files to an external source—such as a portable drive or cloud storage—to ensure you don’t lose anything following a disk failure.
Next, version control lets you synchronize your work with peers who are working on the same projects. In other words, it enables you to collaborate with others without the possibility of someone’s changes overwriting someone else’s work accidentally.
Version control also tracks changes to a project and other data associated with the changes. It makes the process of debugging your code easy too, which we’ll explore in some detail.
Conflicts in files can also be resolved through version control—such as when multiple people have made changes to a file that clash. A version control system highlights the conflicts and provides an opportunity to fix them.
Yet another feature of version control is that it enables work on multiple features of a project at the same time. This gives great scope for experimentation, trial and error. Each feature can be developed independently of the others, and can easily be removed if it doesn’t work out.
Now that you’ve been introduced to the concept of version control, let’s look at how we may already be using version control in our daily lives.
Examples of Version Control in Daily Life
You’ve probably visited the Wikipedia site at some point. You may even have taken the opportunity to update its content, too—as we’re all invited to do. When editing a page, you may also have checked its history. That’s where things get really interesting.
History of the Wikipedia Page for B. R. AmbedkarThe history page shown in Figure 1-2 lists changes to that page. It also records the time of the change, the user who made it, and a message associated with the change. You can examine the complete details of each edit, and even revert back to an older version of the page. This is a good example of a simple form of version control.
Revision history of Google DocsGoogle Docs provides another example of version control that you might experience in daily life. If you check the revision history of a file in Google Docs, shown the figure above, you’ll notice that Google saves the state of your file after every few changes. You can preview the status of the document in any of those previous states—and choose to revert back to it, if needed.
Version Control Systems: the Options
There are two types of version control systems (VCS), known as centralized
and distributed
.
Centralized systems have a copy of the project hosted on a centralized server, to which everyone connects to in order to make changes. Here, the first come, first served
principle is adopted: if you’re the first to submit a change to a file, your code will be accepted.
In a distributed system, every developer has a copy of the entire project. Developers can make changes to their copy of the project without connecting to any centralized server, and without affecting the copies of other developers. Later, the changes can be synchronized between the various copies.
In the earliest version control systems, files were tracked only locally, and only one person could work on a file at a time. Examples of these include Source Code Control System (SCCS) and Revision Control System (RCS), which were common in the 1970s and 1980s.
The next step forward was the introduction of client-server version control systems, which enabled multiple authors to work on the same file (although some still worked on the first come, first served basis). Examples of such systems include Concurrent Versions System (CVS) and Subversion, which are still in use today.
Since around 2005, distributed systems have gained widespread acceptance, with the emergence of systems such as Git, Mercurial and Bazaar.
VCS Is Not CVS
Don’t confuse the abbreviations VCS (version control system) and CVS (concurrent versions system). CVS is just one of the many kinds of VCS.
Back in my freshman year, version control systems were available. However, in the example of my small project, I didn’t use one, simply because I was a beginner and didn’t know they existed. Many people first get introduced to version control systems when they start working with a team. Nowadays, most people get the first taste of version control when dealing with open-source projects.
Enter Git
This book is about Git, a distributed version control system. Git tracks your project history, enabling you to access any version of it back in time. It also allows multiple people to work on the same project, helping avoid confusion when more than one person tries to edit the same file.
Git was created by Linus Torvalds (who is also known for the Linux kernel), and Junio Hamano is its primary developer. Git, as described on the Git website, is a source code management (SCM) solution, but essentially it’s just a type of version control system.
The primary objective behind Git was to implement and design a version control system that was distributed, reliable