Git and the Centralized Workflow Tutorial | A Beginners Guide
Last updated on 11th Aug 2022, Blog, Tutorials
Introduction of GIT WORKFLOW:
It is used for source code management.It is a free and open-source version control system used to handle small to very big projects efficiently.Git is used for tracking modifications in the source code, enabling multiple developers to work together on non-linear development.
let’s explain a scenario before Git:
- Developers used to submit the codes to the central server without having copies of their own.
- Any modifications made to the source code were unknown to the other developers.
- There was no communication between any of the developers
Now let’s look at the scenario after Git:
- Every developer has a full copy of the code on the local systems.
- Any modification made to the source code can be tracked by others.
- There is regular communication between the developers.
What is Git?
Git is a version control system used for tracing changes in computer files.It is commonly used for source code management in software development.
- Git is used for tracking changes in the source code.
- The distributed version control tool is used to source code management
- It permit multiple developers to work together
- It supports non-linear development through its 1000 of parallel branches
Features of Git:
- Tracks history
- Free and open source
- Supports non-linear development
- Creates backups
- Scalable
- Supports collaboration
- Branching is easier
- Distributed development
Git Workflow:
The Git workflow is divided into 3 states:
- Working directory– Modify files in the working directory.
- Staging area (Index)– Stage the files and add snapshots of them to the staging area.
- Git directory (Repository)– Perform a commit that saves the snapshots permanently to Git directory.
Checkout any existing version, make changes, stage them and commit.
Branch in Git:
Branch in Git is used to keep modifications until they are ready.can do work on a branch while the main branch (master) remains stable.After finishing the work, I can merge it with the main office.There are 2 separate branches called “small feature” and “large feature”.
Commands in Git:
- Tracks history
- Free and open source
- Supports non-linear development
- Creates backups
- Scalable
- Supports collaboration
- Branching is easier
- Distributed development
Git Workflow:
The Git workflow is divided into 3 states:
- Working directory– Modify files in the working directory.
- Staging area (Index)– Stage the files and add snapshots of them to the staging area.
- Git directory (Repository)– Perform a commit that saves the snapshots permanently to Git directory.
Checkout any existing version, make changes, stage them and commit.
Branch in Git:
Branch in Git is used to keep modifications until they are ready.can do work on a branch while the main branch (master) remains stable.After finishing the work, I can merge it with the main office.There are 2 separate branches called “small feature” and “large feature”.
Commands in Git:
1. Create Repositories
- git init
2.Make Changes
- add
- commit
- status
3.Parallel Development
- branch
- merge
- rebase
4.Sync Repositories
- push
- pull
- add origin
Git flow branching strategy:
- Develop
- Feature
- Release
- Hotfix
Distributed Version Control System:
- Each programmer has a copy of all the versions of the code on their local systems.
- Distributed VCS move from the client-server approach of central VCS to a peer-to-peer approach.
- They can update the local repositories with new data from the central server and modifiers are reflected in the principal repository.
- Git is one such distributed VCS tool.
How to fix merge conflicts in Git:
Git has just magically handled all of the file updating, and most of the time Git can just handle it.But, there are times when Git does not know how to combine modifications together, and that creates a conflict.A conflict occurs when merging two changes that change the same line in a file.If two commits have modified the same line in a file, Git does not know which commit’s changes to use,AND it will need to make the choice.
How to collaborate with others in Git:
we’ll usually be working with multiple people working on multiple various branches.This is the real power of Git after all: a system to collaborate and trace changes over time amongst more collaborators.For now, let’s continue working as if we are the only person on the project, but let’s adjust workflow a little bit to prepare for when that’s not the case.It’s best practice to not work directly on the main branch.The main branch is supposed to be the “source of truth” for the project—it should be carefully reviewed.Any modification in origin/main becomes the new “source of truth” for anyone else working on the project, so we should not just change it without some thought and review by others.Instead of working on main directly, let’s branch off of main to our own feature branch, and then merge those changes back to main.
Benefits of Gitflow:
- 1. The different types of branches make it simple and intuitive to organize to work.
- 2. The systematic development process permits for efficient testing.
- 3. The use of release branches allows simple and continuous support of multiple versions of production code.
Challenges in Gitflow:
- 1.Depending on the difficulty of the product, the Git flow model could overcomplicate and slow the development process and release cycle.
- 2.Because of the long development cycle, Git flow is historically not able to encourage Continuous Delivery or Continuous Integration.
Conclusion:
I hope this blog helped to understand Git.Learned all about the before Git and after Git, what DevOps is and tools used in DevOps.Various essential topics, like version control systems, centralized version control systems, distributed version control systems, what exactly Git is, benefits of Git, Git workflow, branch in Git, commands in Git.Git is one tool used in DevOps.
Are you looking training with Right Jobs?
Contact Us- Windows Azure Interview Questions and Answers
- Salesforce Architecture Tutorial
- Wrapper Class in Salesforce Tutorial
- salesforce lightning
Related Articles
Popular Courses
- VM Ware Training
11025 Learners
- Microsoft Dynamics Training
12022 Learners
- Siebel Training
11141 Learners
- What is Dimension Reduction? | Know the techniques
- Difference between Data Lake vs Data Warehouse: A Complete Guide For Beginners with Best Practices
- What is Dimension Reduction? | Know the techniques
- What does the Yield keyword do and How to use Yield in python ? [ OverView ]
- Agile Sprint Planning | Everything You Need to Know