Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps Tutorial | Simplilearn
The document provides information on version control systems and Git concepts like distributed version control, forking and cloning repositories, adding collaborators, branching and merging in Git. It includes step-by-step instructions for setting up a Git demo to showcase creating a repository, adding and committing files, connecting to a remote repository on GitHub, forking a project and cloning it locally, creating and switching branches, adding a collaborator, pulling changes, and merging branches.
Introduction to Version Control, importance and benefits of using a VCS in software development.
Distributed Version Control Systems, how it differs from Central VCS, and the concept of local and remote repositories.
Introduction to Version Control, importance and benefits of using a VCS in software development.
Distributed Version Control Systems, how it differs from Central VCS, and the concept of local and remote repositories.
Introduction to Version Control, importance and benefits of using a VCS in software development.
Distributed Version Control Systems, how it differs from Central VCS, and the concept of local and remote repositories.
Introduction to Version Control, importance and benefits of using a VCS in software development.
Git as a distributed version control tool, its capabilities, and how it integrates with GitHub.
Git as a distributed version control tool, its capabilities, and how it integrates with GitHub.
Overview of Git architecture, key operations like committing, pushing, pulling, and essential Git commands.
Introduction to Version Control, importance and benefits of using a VCS in software development.
Processes of forking and cloning repositories in Git, including associated workflows.
Introduction to Version Control, importance and benefits of using a VCS in software development.
Adding collaborators in GitHub projects, and permissions and responsibilities associated with collaboration.
Using branches in Git to develop features separately and the necessity of merging branches later.
Concepts of merging branches and rebasing in Git, their purposes, and how to maintain a linear history.
Concepts of merging branches and rebasing in Git, their purposes, and how to maintain a linear history.
Concepts of merging branches and rebasing in Git, their purposes, and how to maintain a linear history. Process of pulling changes from the remote repository to stay updated with ongoing developments.
Introduction to Version Control, importance and benefits of using a VCS in software development.
Overview of Git architecture, key operations like committing, pushing, pulling, and essential Git commands.
Step-by-step practical demonstration on using Git, including repository creation, forking, branching, and merging.
What’s in itfor you? Version Control System What is Git? Git Architecture Git vs GitHub Fork and Clone Collaborators Commands in Git Git Demo Branch, Merge and Rebase Distributed Version Control System
3.
What’s in itfor you? What’s in it for you?Version Control SystemVersion Control System
4.
Version Control System(VCS) System A File 2.1File 1.1 Repository Version 2File 1 File 2 System A Now we make some changes to the files in System A File 1 ------> saved as File 1.1 File 2 ------> saved as File 2.1 The new files are stored as Version 2 in the repository VCS allows you to store multiple versions of a system file in the remote repository File 1 File 2 Version 1 All the files in System A are stored as Version 1 in the remote repository
5.
What’s in itfor you? What’s in it for you?Version Control SystemDistributed Version Control System
6.
Distributed Version ControlSystem Distributed VCS Developer A Developer B Developer C Version 1 Version 2 Version 3 Version 1 Version 2 Version 3 Version 1 Version 2 Version 3Version 1 Version 2 Version 3 All the developers have the entire copy of code on their local system
7.
Distributed Version ControlSystem Distributed VCS Developer A Developer B Developer C Version 1 Version 2 Version 3 Version 1 Version 2 Version 3 Version 1 Version 2 Version 3Version 1 Version 2 Version 3 Distributed VCS moves from client-server approach of Central VCS to peer-to-peer approach
8.
Distributed Version ControlSystem Distributed VCS Developer A Developer B Developer C Version 1 Version 2 Version 3 Version 1 Version 2 Version 3 Version 1 Version 2 Version 3Version 1 Version 2 Version 3 They can update their local repositories with new data and push it to the central server
9.
Distributed Version ControlSystem Distributed VCS Developer A Developer B Developer C Version 1 Version 2 Version 3 Version 1 Version 2 Version 3 Version 1 Version 2 Version 3Version 1 Version 2 Version 3 Git tool is an example of Distributed VCS
10.
Distributed Version ControlSystem Remote Repository Commit Update Push Pull Commit Update Push Pull Push Pull Commit Update Working Copy Local Repository Working Copy Local Repository Working Copy Local Repository
11.
What’s in itfor you? What’s in it for you?Version Control SystemWhat is Git?
12.
What is Git? GitHubRemote Server Developer 1 Developer 3 Developer 2 Git is used to track changes in the source code Git is a distributed version control tool used for source code management Allows multiple developers to work together Supports non-linear development because of thousands of parallel branches Has the ability to handle large projects efficiently
13.
What’s in itfor you? What’s in it for you?Version Control SystemGit vs GitHub
14.
Git vs GitHub 2 3 4 Itis installed on the local system It is used to manage different versions of the source code It provides a command line to interact with the files 1 2 3 4 GitHub is a service It is hosted on the web It is used to have a copy of the local repository code It provides a graphical interface to store the files 1 Git is a software tool
15.
What’s in itfor you? What’s in it for you?Version Control SystemGit Architecture
Git Architecture Working DirectoryLocal RepositoryStaging Area git add git commit Local After making all the changes, you commit those files to the local repository
19.
Git Architecture Working DirectoryLocal RepositoryStaging Area Remote Repository git add git commit git push Local Remote You can push the committed files to the remote repository
20.
Git Architecture Working DirectoryLocal RepositoryStaging Area Remote Repository git add git commit git push git pull Local Remote git pull fetches all the changes from a remote repository to a local repository
21.
Git Architecture Working DirectoryLocal RepositoryStaging Area Remote Repository git add git commit git push git pull git checkout Local Remote You can create new branches and switch to them as and when required
22.
Git Architecture Working DirectoryLocal RepositoryStaging Area Remote Repository git add git commit git push git pull git checkout git merge Local Remote After you are done with the changes, you can merge the new branches to the master branch
23.
What’s in itfor you? What’s in it for you?Version Control SystemGit Concepts
24.
Forked Test_Repository Fork and Clone GitRebase Pull from a remote Now that we have understood Git and it’s architecture, let’s learn some git concepts Git Concepts Adding Collaborators Branch in Git
25.
What’s in itfor you? What’s in it for you?Version Control SystemFork and Clone
26.
Fork and Clone Hey,I want to propose some changes to your project Sure. Go ahead and Fork it
27.
Fork and Clone Gitallows you to fork an open source repository. When you fork a repository, you create a copy of it on your GitHub account. Someone else’s repository Your own repository Forked Test_Repository Test_Repository Fork
28.
Fork and Clone Afteryou fork a repository, you can clone it and have a copy of it on your local system. Someone else’s repository Your own repository Forked Test_Repository Test_Repository Fork Local Repository Clone to you local computer from GitHub
29.
What’s in itfor you? What’s in it for you?Version Control SystemCollaborators
30.
Collaborators Ok, let meadd you as a Collaborator on GitHub and give you the permission Hey, there are some errors in your code repository, I need to fix it
31.
Collaborators GitHub allows youto work with users from all over the world at any given time Collaborators are GitHub users who are given permission to edit a repository owned by someone else Anonymous UserRepository’s Owner Your repository Access all the files View the files Make changes to the files Commit the files
32.
What’s in itfor you? What’s in it for you?Version Control SystemBranch in Git
33.
Branch in Git Supposeyou are working on an application and you want to add a new feature to the app You can create a new branch and build the new feature on that branch Master branch New branch New Feature Application By default, you always work on the master branch The circles on the branch represent various commits made on the branch
34.
Branch in Git The diagram shows there are 2 new branches You can develop the features you want separately Branch in Git is used to keep your changes until they are ready Master Branch New Branch New Branch Application
35.
Branch in Git The diagram shows there are 2 new branches You can develop the features you want separately Branch in Git is used to keep your changes until they are ready After you develop them completely, you can merge the newly created branches to the master branch New Branch New Branch Master Branch Application
36.
What’s in itfor you? What’s in it for you?Version Control SystemGit Merge
37.
Git Merge a bc d e f g Master Feature Master The base commit of feature branch is b There can be multiple divergent branches
38.
Git Merge a bc d e f g Master Feature Master The base commit of feature branch is b There can be multiple commits for each new branch you create
39.
What’s in itfor you? What’s in it for you?Version Control SystemGit Rebase
40.
Git Rebase a bc d e f Master Feature f_e_ Feature Feature d_ Feature The base commit of feature branch is changed from b to c (tip of master) There is no extra commit history
41.
Git Rebase a bc d e f Master Feature f_e_ Feature Feature d_ Feature The base commit of feature branch is changed from b to c (tip of master) Resulting history is linear with no divergent branches
42.
Git Rebase Git Rebaseis the process of combining a sequence of commits to a new base commit The primary reason for rebasing is to maintain a linear project history Master Feature
43.
Git Rebase Git Rebaseis the process of combining a sequence of commits to a new base commit The primary reason for rebasing is to maintain a linear project history When you rebase, you “unplug” a branch and “replug” it on the tip of another branch (usually master) Master FeatureFeature
44.
Git Rebase Git Rebaseis the process of combining a sequence of commits to a new base commit The primary reason for rebasing is to maintain a linear project history When you rebase, you “unplug” a branch and “replug” it on the tip of another branch (usually master) The goal of rebasing is to take all the commits from a feature branch and put it on the master branch Master FeatureFeature
45.
What’s in itfor you? What’s in it for you?Version Control SystemPull from Remote
46.
Pull from aRemote Suppose these 2 developers are working together on an application
47.
Pull from aRemote They makes changes to their codes and submit it to the remote repository Remote Repository
48.
Pull from aRemote Both of them want to stay updated with the recent changes to the repository Remote Repository
49.
Pull from aRemote They can pull the changes from the remote repository on to their local system Remote Repository Pull from Remote Repository Pull from Remote Repository
50.
Pull from aRemote Your forked Repository Remote Repository Local Repository Pull Your fork Repository Use the following command to check if there has been any change $ git pull <RemoteName> <BranchName> If there is no change, it will notify “Already up- to-date”. If there is an change, it will merge those changes to your local repository You can pull in any changes that have been made from your forked remote repository to the local repository
51.
What’s in itfor you? What’s in it for you?Version Control SystemCommands in Git
52.
Popular Git Commands gitinit Initialize a local Git Repository git add / git add . Add one or more files to staging area git commit –m “commit message” Commit changes to head but not to the remote repository git status Check the status of your current repository and list the files you have changed git log Provides a list of all the commits made on your branch
53.
Popular Git Commands gitdiff View the changes you have made to the file git push origin <branch name> Push the branch to the remote repository so that others can use it Git config –global user.name “Roger” Tell Git who you are by configuring the author name Git config –global user.email roger.1@gmail.com Tell Git who you are by configuring the author email id git clone Creates a Git repository copy from a remote source
54.
Popular Git Commands gitremote add origin <server> Connect your local repository to the remote server and add the server to be able to push to it git branch <branch name> Create a new branch git checkout <branch name> Switch from one branch to another git merge <branch name> Merge a branch into the active branch git rebase Reapply commits on top of another base tip
55.
What’s in itfor you? What’s in it for you?Version Control SystemDemo on Git
56.
Demo on Git 1.Create a Repository Create a “hello-world” folder Move to hello-world folder Create a new Git instance for a project
57.
Demo on Git 1.Create a Repository Create a file called readme.txt in the hello-world folder Check the status of the repository to find out if there have been changes
58.
Demo on Git 2.Create a new file, add something to that file and commit those changes to Git Add the file you just created to the files you would like to commit to change Commit those changes to the repository’s history
59.
Demo on Git 2.Create a new file, add something to that file and commit those changes to Git Add another line to readme.txt and save View the difference between the file now and how it was at your last commit
60.
Demo on Git 3.Create a GitHub account, add username to your Git configuration Sign up to GitHub account by visiting github.com Add your GitHub username to your Git Configuration
61.
Demo on Git 4.Connect your local and remote repositories and push changes Github.com Log in Click the + sign in the top right Create a Remote repository
62.
Demo on Git 4.Connect your local and remote repositories and push changes Connect your local to your Remote Push your file to remote
63.
Demo on Git 5.Fork a project from github.com and clone it locally Github.com/jlord/patchwork Click the fork button at the top right Once the fork is complete, you will get a copy on your account. Copy your fork’s HTTP URL on the right sidebar Someone else’s repository Your own repository Forked Test_Repository Test_Repository Fork Fork Patchwork Repository: We’ll be using github.com/jlord/patchwork
64.
Demo on Git 5.Fork a project from github.com and clone it locally Change the directory Clone the repository onto your computer
65.
Demo on Git 5.Fork a project from github.com and clone it locally Now, you have got a copy of the repository on your local computer which is automatically connected to the remote repository Go into the folder for the fork it created If the original repository you forked from has some changes, you’d want to pull those changes as well. So, you need to add another remote connection to the original repository with its URL Someone else’s repository Your own repository Forked Test_Repository Test_Repository Fork Local Repository Clone to you local computer from GitHubTest_Repository
66.
Demo on Git 5.Fork a project from github.com and clone it locally
67.
Demo on Git 6.Create a new branch on your fork for your contribution Name of the branch is: add-Simplilearn Master Branch add-Simplilearn Create a new branch
68.
Demo on Git 6.Create a new branch on your fork for your contribution Checkout your branch and go onto a new branch Push your update to your fork on GitHub
69.
Demo on Git 7.Add a collaborator to your project Visit the repository’s GitHub page Click settings icon on the right side menu Select the collaborators tab Type the username and click add Add “reporobot” as a collaborator to your forked Patchwork repository’s page
70.
Demo on Git 8.Keep your file up to date by pulling in changes from collaborators It will give a message “Already up to date”, if nothing has changed. If there are changes, it will merge those changes into your local version. Check if Reporobot has made any changes to your branch
71.
Demo on Git 9.Create a new branch, make changes and merge it to the master branch Create a new local repository called test Move to the test folder Create a new git instance
72.
Demo on Git 9.Create a new branch, make changes and merge it to the master branch Create 2 text files “test1” and “test2” in the test repository Add the two files to master branch and make a commit
73.
Demo on Git 9.Create a new branch, make changes and merge it to the master branch Create a new branch “test_branch” Create a new text file “test3”
74.
Demo on Git 9.Create a new branch, make changes and merge it to the master branch Add test3 file to the new branch Move from the master branch to test_branch
75.
Demo on Git 9.Create a new branch, make changes and merge it to the master branch Merge test_branch file to master branch The master branch has all the files now
76.
Demo on Git 9.Create a new branch, make changes and merge it to the master branch Move from the master branch to test_branch Modify test3 file and commit the changes
77.
Demo on Git 9.Create a new branch, make changes and merge it to the master branch Check the test3 file in master branch The file has not been modified in the master branch Check the file in test_branch Switch to the master branch
78.
Demo on Git 10.Rebase the newly created files on to master branch Create 2 new text files test4 and test5 Switch to test_branch
79.
Demo on Git 10.Rebase the newly created files on to master branch Add the files to test branch Commit the files for rebasing
80.
Demo on Git 10.Rebase the newly created files on to master branch List the files in test_branch Switch to the master branch
81.
Demo on Git 10.Rebase the newly created files on to master branch List the files in the master branch Switch to test_branch Rebase master branch
82.
Demo on Git 10.Rebase the newly created files on to master branch Rebase master branch Switch to master branch
83.
Demo on Git 10.Rebase the newly created files on to master branch Rebase test_branch List the files in master branch