October 26, 2024
Git is software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Its goals include speed, data integrity, and support for distributed non-linear workflows.
GIT Download URL: https://git-scm.com/downloads
Explaining Git Operations and Functionality
Git Initialize is used in Git to start tracking changes made to a project. It creates a repository where all changes and updates to the codebase are stored and managed.
- git init
- git add <file name> (to add a specific file)
- git add. (to add all the files)
Git Commit is used in Git to save changes made to a project’s files. It creates a snapshot of the current state of the codebase, allowing developers to track and manage the evolution of their code over time.
- git commit -m “Commit Message”
- Example: git commit -m “Feat: Completed bulk transfer Apis”
The flags available for commit: -m, -am
- [- m]: message for the commit
- [am]: stage changes then commit (no need for git add)
Good commits help preserve the history of a code base.
They help with the following:
Git Branching is a powerful feature in Git that allows developers to create multiple “branches” or separate lines of development within a project. This enables them to work on different features or fixes simultaneously without interfering with each other’s work, and merge them back together when ready.
- git checkout -b <branch-name>
- git branch <branch-name>
- git checkout <branch-name>
- git branch
- git branch -m <new-branch-name>
- git branch -m <old-branch-name> <new-branch-name>
- git branch -d <branch-name>
- git branch -D <branch-name>
- git push origin -d <branch-name>
Git Stash is used in Git to temporarily save changes made to a project’s files without committing them. This allows developers to switch to a different branch or work on a different feature without losing their current progress. The changes can later be retrieved and applied to the codebase as needed.
- git stash
- git stash list
- git stash show stash@{0}
- git stash apply
- git stash apply stash@{0}
- git stash save “WIP: making progress on foo”
- git stash branch ‹optional stash name›
- git checkout ‹stash name› — ‹filename›
- git stash pop (tip: doesn’t remove if there’s a merge conflict)
- git stash drop
- git stash drop stash@{n}
- git stash clear
Git Logs is used in Git to display a recorded history of all the commits made to a project. It shows information such as the commit message, author, date, and unique identifier for each commit, enabling developers to track changes made to the codebase and identify when and by whom they were made.
- git log — <limit>
- git log — — oneline
- git log -p
- git log — — stat
- git log — — grep=“‹pattern>”
- git log — — since=“yesterday” || git log — since=“2 weeks ago”
Git Remote is used in Git to manage connections to remote repositories, typically hosted on services like GitHub or GitLab. It allows developers to push and pull changes from a remote repository, collaborate with other developers, and share their code with the wider community.
Purpose: To create repositories so that multiple developers can work on them simultaneously.
For More Details Visit this Link: https://kinsta.com/blog/monorepo-vs-multi-repo/
- git remote -v
- git remote add <name> <URL>
- git remote remove <name>
- git push <remote> <branch>
- git pull <remote>
Some of the popular Git Gui Tools