Git
Git is distributed version control system which is free and open source software (FOSS). It is a tool to track the changes in the code. We save an initial version of code in the git and then update over the time. We can look back all the changes done so far. Github is the website to host the repositories online.
Once we have made changes local repository on the computer and ready to put in git, we need to tell git to track them through add command, save file through commit command and then upload the changes to remote repository using push command. Thus we can keep track the version history and also isolate the changes.
SSH (Secure SHell protocol is used for authentication and it is secure and convenient way to log into remote servers) keys need to be generated which consists of pair of keys, private and public keys. Public key is shared with the world via GitHub while the private key is kept secured on one's computer. When we try to connect with GitHub, SSH client provides private key to prove who you are. The GitHub then verifies with the corresponding public key.
Work Flow
Git Branching
Master Branch : The main branch (often named main
or master
) represents the stable and production-ready version of the code. Feature branches are created and merged into the main branch once the new features are thoroughly tested and approved.
Feature Branch: A feature branch is created to work on a specific feature or enhancement. It allows developers to isolate their work from the main codebase until the feature is complete and ready for review.
Hotfix Branch: A hotfix branch is created to address critical issues or bugs in the production code. It allows developers to make urgent fixes without disrupting ongoing development in feature branches.
Uses
It enables tracking changes in files over time, providing developers with a comprehensive history of revisions. This decentralised approach allows for collaboration among multiple developers, facilitating simultaneous work on different aspects of a project.
One of its key features is branching and merging, which supports parallel development by allowing developers to work on separate branches of code and later integrate their changes seamlessly. This promotes an efficient and organized workflow, essential for large-scale projects.
Git ensures data integrity and backup through its robust system, minimizing the risk of data loss or corruption. Its flexible workflow, powered by various commands, offers developers the freedom to customize their working environment to suit their specific needs and preferences.
Each change made to the codebase is recorded through commits, accompanied by meaningful messages that provide context and clarity about the modifications.
Git also excels in its search functionality, enabling developers to efficiently navigate through the project's history and revert to previous versions if needed.
Additionally, Git supports hosting on various platforms like GitHub, GitLab, and Bitbucket, making it accessible and adaptable to different hosting environments.
Git revolutionises version control in software development, empowering teams to collaborate effectively, manage code changes seamlessly, and maintain a high level of productivity throughout the development lifecycle.
๐ด๐ถ๐ ๐ฐ๐ผ๐บ๐บ๐ถ๐ -๐ฎ -๐บ "๐ฐ๐ผ๐บ๐บ๐ถ๐ ๐บ๐ฒ๐๐๐ฎ๐ด๐ฒ": Commit all tracked changes with a message.
๐ด๐ถ๐ ๐๐๐ฎ๐๐๐: Show the state of your working directory.
๐ด๐ถ๐ ๐ฎ๐ฑ๐ฑ ๐ณ๐ถ๐น๐ฒ_๐ฝ๐ฎ๐๐ต:Add file(s) to the staging area.
๐ด๐ถ๐ ๐ฐ๐ต๐ฒ๐ฐ๐ธ๐ผ๐๐ -๐ฏ ๐ฏ๐ฟ๐ฎ๐ป๐ฐ๐ต_๐ป๐ฎ๐บ๐ฒ: Create and switch to a new branch.
๐ด๐ถ๐ ๐ฐ๐ผ๐บ๐บ๐ถ๐ --๐ฎ๐บ๐ฒ๐ป๐ฑ:Modify the last commit.
๐ด๐ถ๐ ๐ฝ๐๐๐ต ๐ผ๐ฟ๐ถ๐ด๐ถ๐ป ๐ฏ๐ฟ๐ฎ๐ป๐ฐ๐ต_๐ป๐ฎ๐บ๐ฒ: Push a branch to a remote.
๐ด๐ถ๐ ๐ฝ๐๐น๐น: Fetch and merge remote changes.
๐ด๐ถ๐ ๐ฟ๐ฒ๐ฏ๐ฎ๐๐ฒ -๐ถ: Rebase interactively, rewrite commit history.
๐ด๐ถ๐ ๐ฐ๐น๐ผ๐ป๐ฒ: Create a local copy of a remote repo.
๐ด๐ถ๐ ๐บ๐ฒ๐ฟ๐ด๐ฒ: Merge branches together.
๐ด๐ถ๐ ๐น๐ผ๐ด --๐๐๐ฎ๐: Show commit logs with stats.
๐ด๐ถ๐ ๐๐๐ฎ๐๐ต: Stash changes for later.
๐ด๐ถ๐ ๐๐ต๐ผ๐ ๐ฐ๐ผ๐บ๐บ๐ถ๐_๐ถ๐ฑ: Show details about a commit.
๐ด๐ถ๐ ๐ฟ๐ฒ๐๐ฒ๐ ๐๐๐๐~๐ญ or git reset "commit #code" (obtained from log): Undo the last commit, preserving changes locally.
๐ด๐ถ๐ ๐ฎ๐ฝ๐ฝ๐น๐ ๐ฝ๐ฎ๐๐ฐ๐ต_๐ณ๐ถ๐น๐ฒ_๐ป๐ฎ๐บ๐ฒ: Apply changes from a patch file.
๐ด๐ถ๐ ๐ฏ๐ฟ๐ฎ๐ป๐ฐ๐ต -๐ ๐ฏ๐ฟ๐ฎ๐ป๐ฐ๐ต_๐ป๐ฎ๐บ๐ฒ: Delete a branch forcefully.
๐ด๐ถ๐ ๐ฟ๐ฒ๐๐ฒ๐: Undo commits by moving branch reference.
๐ด๐ถ๐ ๐ฟ๐ฒ๐๐ฒ๐ฟ๐: Undo commits by creating a new commit.
๐ด๐ถ๐ ๐ฐ๐ต๐ฒ๐ฟ๐ฟ๐-๐ฝ๐ถ๐ฐ๐ธ ๐ฐ๐ผ๐บ๐บ๐ถ๐_๐ถ๐ฑ: Apply changes from a specific commit.
๐ด๐ถ๐ ๐ฏ๐ฟ๐ฎ๐ป๐ฐ๐ต: Lists branches.
๐ด๐ถ๐ ๐ฟ๐ฒ๐๐ฒ๐ --๐ต๐ฎ๐ฟ๐ฑ: Resets everything to a previous commit, erasing all uncommitted changes.
git checkout branch-name
Comments
Post a Comment