GIT: Source code management
Sagar Kulkarni
DevOps Engineer/TEMS | CI/CD |Jenkins | AWS |Docker | Ansible | GIT |K8S | Monitoring
Source code management (SCM) is the practice of tracking and controlling changes to source code throughout the software development lifecycle. SCM involves using specialized tools and practices to manage the versioning, collaboration, and organization of source code files. It allows multiple developers to work on a project simultaneously, keeps a history of changes, facilitates code merging and branching, and helps maintain the integrity and traceability of the codebase.
Type of source code management
Centralized SCM:
Subversion (SVN): A centralized version control system where a single repository stores the entire history of the project. Developers typically check out the latest version, make changes, and commit them back to the repository.
Distributed SCM:
Git: A distributed version control system designed to handle everything from small to large-scale projects with speed and efficiency. Each developer maintains a local copy of the repository, allowing them to work offline and commit changes to their local repository before synchronizing with a central repository.
Available tools:
Git: Git is a distributed version control system (VCS) that allows developers to track changes in source code during software development. It provides features like version history, branching, merging, and collaboration. Git operates locally on the developer's machine, allowing them to work offline and commit changes to their local repository. It's known for its speed, efficiency, and flexibility.
GitHub: GitHub is a web-based hosting service for Git repositories. It provides a platform for collaborative software development and offers features like pull requests, issue tracking, code reviews, project management tools, and documentation.
GitLab: GitLab is a web-based DevOps platform that provides both source code management and a variety of other features like CI/CD pipelines, issue tracking, project management, and container registry. It is similar to GitHub but aims to offer a complete end-to-end DevOps solution in a single application.
Bitbucket: Bitbucket is a web-based platform that supports both Git and Mercurial repositories. It offers features like source code hosting, pull requests, issue tracking, code reviews, and integration with other Atlassian tools such as Jira and Confluence. Bitbucket is popular among smaller development teams, startups, and organizations that use other Atlassian products.
While Git is the core version control system that allows developers to manage source code changes locally, GitHub, GitLab, and Bitbucket provide platforms for hosting Git repositories and additional collaboration and project management features.
Git architecture?
GIT Important Commands
git init
The command git init is used to create an empty Git repository.?
Git?clone
Git clone is a command for downloading existing source code from a remote repository
git clone <https://name-of-the-repository-link>
Git?branch
By using branches, several developers are able to work in parallel on the same project simultaneously.
git branch <branch-name>
This command will create a branch?locally. To push the new branch into the remote repository,?
git push -u <remote> <branch-name>
Viewing branches:
git branch or git branch --list
Deleting a branch:
git branch -d <branch-name>
Git?checkout
We use?git checkout?mostly for switching from one branch to another.?
git checkout <name-of-your-branch>
git checkout -b <name-of-your-branch>
Git?status
The Git status command gives us all the necessary information about the current branch.?
git status
Git?add
We need to use the git add command to include the changes of a file(s) into our next commit.?
领英推荐
git add <file>
Git?commit???: git commit -m "commit message"
Git?push?: git push <remote> <branch-name>
GIT Merge and Rebase
Git merge and rebase are two different strategies used to incorporate changes from one branch into another branch in Git version control.
Git Merge:
Git Rebase:
Git pull and fetch
In Git, both git pull and git fetch are used to update your local repository with changes from a remote repository.
Git Fetch:
Git Pull:
This branching strategy consists of the following branches:
git revert
git revert <commit_id>
git reset
·??????git reset <commit_id>
git stash
In Git, the git stash command is used to temporarily save changes that you have made to your working directory, allowing you to switch branches or perform other operations without committing your changes.
git cherry-pick
Is used to apply a specific commit from one branch to another. It allows you to pick and apply individual commits, copying them to a different branch.
What is the meaning of “Index” or “Staging Area” in GIT
The index serves as a holding area for changes that are ready to be committed. It acts as a snapshot of your working directory that is prepared for the next commit.
How do you find a list of files that has been changed in a particular commit?
git diff-tree –r {commit hash}
-r flag allows the command to list individual files
commit hash lists all the files that were changed or added in the commit.
What is the functionality of git clean command?
The git clean command removes the untracked files from the working directory.
How to change any older commit messages?
You can change the most recent commit message with the git commit —amend command.
git remote
git remote is a command that allows you to manage connections to remote repositories. It provides a way to interact with and manipulate remote repositories that are linked to your local repository.
Senior Manager at Giesecke+Devrient
1 年??