Git - Devops tool
Rahul Chanda
MTech Data Science | Big Data Engineer |Apache Spark|Hadoop (HDFS)|Python|Microsoft Azure|Databricks
Before GIT was introduced i.e. before 2008, software developers used to have either central repository or shared location to maintain project code while working in team. It used to be very hard to maintain the history of changes and tedious to push stable code in production.
After GIT introduced i.e. after 2008, it made easy for developer to maintain and track the history of files and allow developers to push stable code in production with minimum deployment issues.
In this blog will study about GIT basic commands and how to use GIT in development.
What is GIT?
1. It is devops tool which controls and tracks the version of all files of our project code.
2. It saves the history of each files.
3. It is distributed which allows mutiple user to work together
4. Maintain client specific branches in same project
5. It provides systematic process to deploy code in main project with minimum deployment issues.
GIT Architecture
1. Git repository - tracks and saves the history of all changes made to the files in a Git project.
2. Git branch - Copy of local code inside repository. We make code changes by creating branch?
3. Git clone - Copy of that repository at in a new local directory, at another location
4. Git staging - commits can be formatted and modified before completing the commit. Git considers changes that are in staging area.
5. Fork - It is used to copy others repository into our repository
How to use GIT?
1. Create a local repository in git from main branch
2. Clone/Copy branch from local repository to local working directory
3. Make your changes in files
4. Create a pull request for integrating changes in main branch
5. Address review comments if any present
6. Merge pull request in main branch
7. Delete your local branch
Why GIT?
1. Git Committing, branching, merging all are optimized for a better performance.
2. Git branching model lets you have multiple local branches which are independent of each other.
3. Git is distributed in nature
4. Open Source
领英推荐
Where to use GIT?
GIT is most widely used in all software development projects to track the history of the files.
Important GIT Commands
1. Cloning the repository -
git clone <repository>
2. Creating branch from repository -?
git checkout -b <branch-name> <repository-name>
3. Adding files in staging area after changes in working directory
git add <file-name>
4. Committing all the changes t remote repository
git commit -m <commit-msg>
git push <target-repository>
5. Checking difference between working directory and staging/local repository
git diff
6. Deleting branch from repository
git branch -D <branch-name>
7. Redo the commits
git reset <commit>?-> preserves changes locally
git reset --hard <commit>
8. Downloads all history from the remote tracking branches
git fetch -all
9. Updates your current local working branch?
git pull <local-reposiory>
10. Integrate changes from one branch onto another branch instead creating new commit and preserving logs
git checkout <local-branch>
git rebase <master-branch>
11. Git Tagging -
git tag <tag-name> <commit-hexcode>
So we have all important commands which are used while deploying code.
Kindly let me know any important commands if missed.