Professional Documents
Culture Documents
Git_and_its_best_practices-timestamp
Git_and_its_best_practices-timestamp
Practices
------------------------------------------------------------------
Introduction to Git:
Git is a distributed version control system used to track changes in source
code during software development. It allows multiple developers to collaborate
on projects efficiently.
Key Concepts:
=> Repository(Repo): A collection of files and their revision
history.
Installing Git:
=> Git installation is important for the availability of Git
compatible version and all its functions and features.
https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
Configuring Git:
=> Now that you have Git on your system, you’ll want to do a few things to
customize your Git environment. You should have to do these things only once on
any given computer; they’ll stick around between upgrades. You can also change
them at any time by running through the commands again.
=> On Windows systems, Git looks for the .gitconfig file in the $HOME
directory (C:\Users\$USER for most people). It also still looks for
[path]/etc/gitconfig, although it’s relative to the MSys root, which is wherever
you decide to install Git on your Windows system when you run the installer.
=> You can view all of your settings and where they are coming from using:
$ git config --list --show-origin
=> You can set username and email in git configs using:
https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup
git rebase
Conflicts:
=> Merge Conflict: When Git is unsure what changes to apply, so it
leans on developer for help and notifies them for a merge conflict.
Developer's job then becomes to help git determine which proposed change is
most accurate and up to date.
II.When a developer deletes a file, but another developer edits it, and they
both try to merge their changes to the same branch.
III.When a developer deletes a line, but another developer edits it, and they
both try to merge their changes to the same branch
There is a high probability that when two developers or more works on same
module, conflict will definitely occur.
Good software developers communicate with teammates. Keep your team aware of
what files you will be touching and coordinate with your Product Manager and SCRUM Master
to avoid working on features that conflict with other features.
Even if you are working alone, pretend you are working on a team by:
-> Mandate it as a practice for approvals of all team members before merging
any Merge/Pull Request.
-> Avoid allowing pull requests(PR) to become stail by informing team on regular
basis that your PR is ready to merge.
-> Avoid changing same lines of code before merging a prior change.
Best Practices:
=> Use Meaningful Commit Messages: Describe the purpose of each commit concisely.
=> Branching Strategy: Adopt a clear branching model (e.g., GitFlow) for managing feature
development and releases.
=> Git Ignore: Utilize .gitignore files to exclude unnecessary files from version control.
=> Pull Requests: Use pull requests for code review and integration of changes.
=> Code Reviews: Conduct thorough code reviews to maintain code quality and catch errors
early.
=> Use Aliases: Define Git aliases for frequently used commands.
=> Interactive Rebase: Squash or reorganize commits before merging into the main branch.
=> Stash: Temporarily store changes that are not ready to be committed.
=> Remote Repositories: Always push changes to remote repositories for backup.
(Git + Dictator)