Table of contents
What is a VCS (Version Control System)?
A version control system (VCS) or version control software automates the process of version control. It tracks changes to a file or set of files over time so that you do not have to manage file versions manually or with custom automation scripts. A version control system keeps a complete history of your code and other files, allowing you to return to a previous version if needed.
Centralized Version Control Systems
Here, there’s a central repo shared with all the developers, and everyone gets their working copy. Whenever you commit, the changes get reflected directly in the repo. Unlike distributed systems, developers directly commit to the remote. Which means they may affect files knowingly or unknowingly.
Distributed Version Control Systems
In distributed systems, there is a local copy of the repo for every developer on their computers. They can make whatever changes they want and commit without affecting the remote repo. They first commit to their local repo and then push the changes to the remote repo. This is the type used majorly today.
In the Centralized VCS, every commit was directly happening to the, say, remote repo. But in distributed VCS, it first happens in the developer's local repo, and then they send those changes to the remote. Remote repo is a git repo on a server hosted by any such providers like GitHub, Bitbucket, etc.
Git and GitHub
Git
Git is a popular and widely used distributed version control system designed to manage and track changes to software code and other digital assets. Developed by Linus Torvalds in 2005, Git is a fast, efficient, and flexible tool that can handle projects of any size. It allows developers to create, clone, and manage repositories and track changes over time using commits. One of Git's key features is its distributed nature, which allows users to work offline and merge changes easily. Git also offers powerful branching and merging capabilities, making it easy to experiment with new ideas and collaborate on different parts of a project. Git is an essential tool for modern software development, used by individuals and corporations of all sizes.
GitHub
GitHub is the world's largest platform for open-source software development, offering web-based tools and services for hosting and collaborating on software projects using Git. It allows developers to store and share code repositories, collaborate with others, and contribute to open-source projects. With features such as issue tracking, pull requests, and project management tools, GitHub is a powerful and flexible tool for modern software development. Its extensive community of developers and integrations with other tools and services make it an essential platform for software development.
Tasks
Task 1: Install Git on your computer
To install Git on your computer, simply download the appropriate installer from the Git website and follow the prompts to complete the installation. Once installed, you can use Git to manage and track changes to your software code and other digital assets. To verify that Git has been installed correctly, open the command line or terminal and type 'git --version'. Installing Git is an easy and essential step for modern software development.
Task 2: Create a free account on GitHub
To create a free account on GitHub, simply visit the GitHub website and click on the 'Sign up' button in the top right corner of the homepage. Enter your desired username, email address, and password, then choose your plan and complete the verification process.
Exercises
Exercise 1: Create a new repository on GitHub and clone it to your local machine.
To create a new repository on GitHub and clone it to your local machine, follow these steps:
Sign in to your GitHub account and navigate to your dashboard.
Click on the "+" sign in the top right corner and select "New repository" from the dropdown menu.
Enter a name for your repository and a brief description (optional).
Choose whether you want your repository to be public or private.
Select the option to add a README file to your repository.
Click on the "Create repository" button to create your new repository.
Once your repository is created, copy the HTTPS URL for your repository.
Open your terminal or command prompt on your local machine and navigate to the directory where you want to clone your repository.
Type "git clone" followed by the HTTPS URL for your repository, then press Enter.
git clone https://github.com/ArnavS1999/basicgit.git
Once the cloning process is complete, you will have a local copy of your repository on your machine that you can work on and commit changes to.
Exercise 2: Make some changes to a file in the repository and commit them to the repository using Git.
Let's create a .txt file, add some content or make the desired changes to the file and save it.
Type "git add" to stage your changes for commit. This command stages all changes in the repository.
Type "git commit -m 'commit message'" to commit your changes to the repository. Be sure to replace 'commit message' with a short, descriptive message that summarizes your changes.
After entering "git commit -m 'commit message" the terminal displays a message "Author identity unknown".
"Author identity unknown". means that there is no author to make or save changes to VCS.
To solve this issue run these commands:
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
After adding your Username and your mail, run the "git commit -m 'commit message'" again.
- The file that was created has been committed successfully to the local repository!
Exercise 3: Push the changes back to the repository on GitHub
- To push the changes to the GitHub repository, we use the command:
git push -u -f origin
After entering the command it will ask for GitHub Username and Password.
Enter the Username but for the password generate your special access token and paste it and press Enter.
- After Enter Files will be pushed from the local repo to the remote repo.
Thank you for reading!
Happy Learning!!