# Mastering Git and GitHub: A Guide for Freshman Coders.

![](https://lh4.googleusercontent.com/x0YXM5jOk9Hh9AFT7M_NE9hQCbXMrLg-9UsRUkdlO61D6SM6PJWxed-vPjwHms0IN5h5TRFK7LV-a7TH6y2sQvEGZWjaGExpT9reI4RZ1EcKgKoVbvjr-szHFfgoNif2ghG0MZ7MBKL7G0cr1wcYcPQ align="left")

Are you a freshman coder looking to level up your skills and collaborate effectively on coding projects? Look no further! Mastering Git and GitHub is a fundamental skill set that will empower you to take control of your code, track changes, and seamlessly collaborate with other developers. With this comprehensive guide, you can walk through the essentials of Git and GitHub, demystify the world of version control, and develop the confidence necessary to navigate your coding journey. Whether you're working on personal projects or collaborating with a team, this guide will equip you with the skills needed to manage your codebase efficiently and contribute effectively to the world of software development.

## What are Git and GitHub?

Git and GitHub are essential tools for version control and collaboration in software development. As a freshman coder, it is important to understand these basics before embarking on your coding journey. Git is a distributed version control system that allows you to track changes in your codebase over time. It provides a structured way to manage different versions of your code, making it easier to revert to previous versions if needed and ensuring the integrity of your project. Git also enables collaboration by allowing multiple developers to work on the same project simultaneously.

GitHub, on the other hand, is a web-based platform that hosts Git folders also known as repositories. It provides a graphical user interface and additional features that enhance collaboration and project management. GitHub allows you to store your code in repositories, create branches for different features or bug fixes, and merge changes made by different contributors. By understanding the basics of Git and GitHub, you gain the ability to track changes, manage versions, and collaborate effectively with other developers. This knowledge is highly valuable throughout your coding journey and equips you to become a more efficient and skilled programmer.

## Essential Git Commands for Freshman Coders

To navigate Git effectively, mastering essential Git commands is a key factor. These commands allow you to perform various tasks such as initializing a repository, adding and committing changes, branching, merging, and pushing your code to a remote repository. Here are some key Git commands that every freshman coder should know:

git config –global [user.name](http://user.name) “your name”: Introduces your user name to git  
git config –global [user.email](http://user.email) your email: Introduces your user email to git  
git pwd: Checks your current working directory

git mkdir “Name of the Root folder”: Creates a new folder directory (Repository)

![](https://lh3.googleusercontent.com/vB2j3cR3wuKeMm1LjsWPcG3LF5JzvDJjN4w_WDURVJhg9VCZx-Pk3BNrOOZ_WGzCP7oWRHChG0eJFS9qeaHber_-8qa6NNav9PCHzVZX1uSMuyH5s-vS2K0g4-DCf_Hq5PmXyK8yWB08jPz2pijlyNw align="left")

git cd ‘’Name of created folder”: Enables you to work on the created folder

![](https://lh3.googleusercontent.com/U1tr5pjwmT-a_sDiMyxfz065Rk6emuuM6F0hb_Rx4xoj5BXkEPLHOX__GRN7P6-8juI836Z5tkLCkFRgoQjx68hSSMrsH5o4VcNoZa9cYE-ToAGjZy9k8NvpbR4yny4_Ivu-qBxlYYcRSzfSPqfNn7g align="left")

git clone \[URL\]: used to obtain a repository from an existing URL

![](https://lh3.googleusercontent.com/-FzPrnbQMjvl0RGWpcGtFmn3xN4sBFLUlMS0Lp0kFAr9VzFFv094vD_6NO0l84Ev-9sn5nepORKOZkItYPIe7bGELbZyeygTY4-G4wFY0-JM20txH6v9_gDaRnFTLS6thKnIuMQIO6w47hbVCO5mC-k align="left")

Touch [README.md](http://README.md): Creates an empty file named README

![](https://lh3.googleusercontent.com/6moYcOIoNw_m4XZozlVkhTNEC3x50LSK0f2VALOLVTNMbyzzTEP4nXH0FnubZXc1miI3Jfahhi8vfmcYwQP-o-JiaAHP0T5XeL_TklgMSsmjLXH4C2r2MHkM4srwOBgtqnLNa83fLWTtnvPu1kQYIMA align="left")

echo ”Content” &gt; [README.md](http://README.md): Insert content into the [README.md](http://README.md) file

cat [README.md](http://README.md): confirms the content of the [README.md](http://README.md) file

![](https://lh3.googleusercontent.com/txUW_zA8L_tg4PyitIY9WgLHDZ8GmMKyG6lUryg8eQjJZlLRpFlN9K1ubb1p07zj_EUNAheC-Pn-3UEC54-d7KkdebbXV_zYdggC46oSmtlkL7DL9A7xrvXMD91jrvwRvWppurUmEL9N9qGZaNdgX9M align="left")

git init: Initializes a new Git repository in your project directory.

![](https://lh5.googleusercontent.com/OFF4o5uNHA1x-J3Y7DLbFEYCD99228fhnZlWKbHxand7T3x8DXoJJDVdvy3l10Lag9q715I44gFeRw0Ph8IryO7dgfy0i4sdsREnNiFHzFm2c5M5xHuihikciip4aHAulafMCN6JCb_wl9z9U7VFJdY align="left")

git add &lt;file&gt;: Stages a file or multiple files for commit.

git commit -m "commit message": Commits the staged changes to the repository with a descriptive message.

![](https://lh6.googleusercontent.com/yJqY5YtWhoPTRZEF2iJvx1xHxjScrhKgikMMTnf8M2zgrUGhooOKK9_ZkOA4lhbvdbV0wqWVROezz0fdp0rjDhDdQ42YOSRpEDstNZWrtJ-_BSJ-XlvyC193kXTpwy81CNNhtaK-a_yOONZdBtBAexg align="left")

git branch: Create a branch from the root folder also, lists all branches in the repository.

git checkout &lt;branch&gt;: Switches to the specified branch.

![](https://lh4.googleusercontent.com/jm7K-43LzX2FqlPj7Dx3DjyubHJlaqRcYdYL4qcl6nbgqR01F6Bc1CA1tiV5i9Dh4vTVgIbC08ddrfyLbog_1EckUWEruANIYTN0BSvwo8sVH4UqeMdKfbhkJQIm0DVX5SxkQKEtfdHehj6bQFoX2Cs align="left")

git merge &lt;branch&gt;: Merges changes from the specified branch into the current branch.

Git remote add &lt;URL&gt;: To push your repository online,

![](https://lh6.googleusercontent.com/tjaFxaWQjKAYpJw1j9Mh7CeQ4FmjCcudFAY6qN4i9UAfQ63l5ehNA6wiErJnE0mcnpWRk0cRohw-qJZ9LUyTsNM_OEth4BKvd-56tamHMviLjvv7SLs_onHYbEiL8IhQ93rn_Css2XyBqjv-fbz7Hts align="left")

git push: Pushes your local commits to a remote repository, such as GitHub.

![](https://lh4.googleusercontent.com/q4HyJjhnWNN82UbK1n7JP6UB2L44I6WjstZg5jMo26nPuCA3aPAFB8W4oE_riNDup6JEFGVv9oTXJoR4zQJayvCrbaIVnfrWmMCTSyGswP46hwYtC0Gy9DHiUewKAd2QDLX1QYvM6hNfaaPSfhJPcUo align="left")

git pull: Fetches and merges change from a remote repository into your local repository.

git status: Gives a clear display of all files on your repository (tracked and untracked).

![](https://lh4.googleusercontent.com/bu8UFJhwmi0p1VlITZlGnV3_Pv_-Csb8uqylX9_0l55_jJWWwwvNo0zqmo-wBAlUt2AGbZBbbSb7BXhNi2RheKaJ6x9CJgo9DUH2wT2qLYSj0HQAp1sZoXvWgrXLEHjo5Oxi8AVoPG69RC0OJpPTNow align="left")

git rm –cached &lt;file name&gt;: Removes a file from your repository.

git code .: Opens vs code IDM on your PC.

Git checkout &lt;Branch Name&gt;: Switches from one branch to another.

Git checkout -b&lt;Branch Name&gt;

## Collaborating on GitHub

GitHub offers powerful collaboration features that facilitate teamwork and code review employing Pull Requests and Branching Strategies. As a freshman coder, it's important to understand how to leverage these features to collaborate effectively with other developers.  A pull request allows you to propose changes to a repository and request that they be reviewed and merged into the main codebase. Thus, enabling a structured code review process, where other developers can provide feedback, suggest changes, and ensure the quality of the code before merging it. When collaborating on GitHub, it is common to work on different branches. Branches allow you to isolate changes and work on specific features or bug fixes without affecting the main codebase and deleting branches after they have served their purpose. This ensures that the main codebase remains stable while you experiment and make changes on your branch. Once your changes are complete and reviewed, you can merge them into the main branch using pull requests. keep in mind that it is vital to follow good branching strategies to ensure a smooth collaboration process.

## Final Words

With a good understanding of basic Git commands, you can collaborate seamlessly with other developers, and maintain a well-organized and efficient development workflow on GitHub. Having grasped the principles and utility of Git and GitHub, it's time to get back to work and diligently monitor the versions of your codebase. Enjoy your coding life!
