"This is a documentation for Git and GitHub for those who are kickstarting thier joruney"
By Shivam
01/09/2025
Welcome to the onboarding documentation for Git and GitHub at ChaiCode! This guide is designed to help you navigate the essential tools that are fundamental to modern software development.
Git is a powerful version control system that allows developers to track changes in their code, collaborate with others, and manage project history efficiently. GitHub, on the other hand, is a cloud-based platform that hosts Git repositories, enabling seamless collaboration among team members.
At ChaiCode, we believe that mastering Git and GitHub is crucial for every developer. These tools not only streamline the development process but also foster a culture of collaboration and transparency. By using Git and GitHub, you can easily contribute to projects, review code, and maintain a clear record of your work. This documentation will guide you through the basics of using these tools, ensuring you have the knowledge and skills to thrive in our collaborative environment. Let's embark on this journey together and unlock the full potential of version control!
VCS stands for Version Control System. It is a tool that helps manage and track changes to source code or other files over time. VCS is essential for software development and other projects where maintaining a history of changes, collaboration, and versioning is critical
Git is a version control system VCS designed to track changes in source code and collaborate efficiently with others. It is widely used for software development due to its speed, flexibility, and support for non-linear workflows (e.g., branching and merging).
GitHub is a cloud-based platform that provides hosting for Git repositories. It serves as a collaborative space where developers can store, manage, and share their code with others. GitHub enhances the capabilities of Git by offering a user-friendly interface and additional features that facilitate teamwork and project management.
To install Git, you can use command line or you can visit official website and download the installer for your operating system.
Git is available for Windows, macOS, and Linux and is available at here
Let’s setup your email and username in this config file. I would recommend you to create an account on github and then use the email and username that you have created.
git config --global user.email "your-email@example.com"
git config --global user.name "Your Name"Now you can check your config settings:
git config --listCreating a GitHub account is a straightforward process. Follow these steps to get started:
Go to the GitHub homepage.
On the top right corner of the page, click on the Sign up button.
You will be prompted to enter the following information:
GitHub may ask you to verify your account by completing a CAPTCHA. Follow the on-screen instructions to complete this step.
You will be presented with different plans. You can choose the Free plan, which is suitable for most users starting out.
Check your email inbox for a verification email from GitHub. Click on the verification link in the email to confirm your email address.
You have successfully created your GitHub account. You can now start exploring repositories, creating your own projects, and collaborating with others.
Example:
git clone https://github.com/ChaiCode/example-repo.gitNavigate to the folder where you want to clone the repository using the cd command:
cd /path/to/your/folderUse the git clone command with the copied URL:
git clone <repository-url>For example, if the repository URL is https://github.com/ChaiCode/example-repo.git
git clone https://github.com/ChaiCode/example-repo.gitAfter cloning, change into the repository directory:
cd repoThese are some of the most commonly used commands in git. They will help you navigate your project and manage it efficiently.
To check your git version, you can run the following command:
git --versiongit init
2. Show the status of the working
directory
git status
git add .git commit -m "message" git push -u origin maingit push git log git log --oneline
Commit messages clarify what and why changes were made, aiding collaboration and debugging. They provide a clear history of the codebase, improving project traceability and helping developers quickly understand changes without reviewing the code, ensuring efficient workflows.
Use the present tense ("Add feature" not "Added feature").
Capitalize the first letter.
Keep the message short (50 characters or less).
Use prefixes like fix:, feat:, chore:, docs: for categorization.
Example
feat: Add tea selection feature fix: Resolve login issue for tea enthusiastsdocs: Update README with chai varietiesBranches are a way to work on different versions of a project at the same time. They allow you to create a separate line of development that can be worked on independently of the main branch. This can be useful when you want to make changes to a project without affecting the main branch or when you want to work on a new feature or bug fix.
To create a new branch, you can use the following command:
git branch
git branch bug-fix
git switch bug-fix
git log
git switch master
git switch -c dark-mode
git checkout orange-modeImportant points:
git checkout main
git pull origin maingit checkout <your-feature-branch>Resolve Any Conflicts (If Any): If there are conflicts when rebasing or merging, Git will stop and highlight the conflicted files. You will need to resolve the conflicts manually in these files.
There is no magic button to resolve conflicts. You have to manually resolve the conflicts. Decide, what to keep and what to discard. VSCode has a built-in merge tool that can help you resolve the conflicts. I personally use VSCode merge tool. Github also has a merge tool that can help you resolve the conflicts but most of the time I handle them in VSCode and it gives me all the options to resolve the conflicts.
git add <conflicted-file>Copy codeHow to create a pull request
git push origin <your-feature-branch>Title: Provide a meaningful title that summarizes your changes. Description: Write a detailed description of your changes, why they are necessary, and any relevant context. Include screenshots or references to issues, if applicable. Base and Compare Branches: Ensure the base branch (e.g., main) and your feature branch (e.g., feature-branch) are correctly selected. Screenshot reference: The pull request form with the title, description, and branch dropdowns highlighted.