Git/Github Cheat code For Working In Teams
I recently started leading a team of Beginners and it took a while to realize that a major hindrance was their inability to collaborate in a team because they didn't fully understand Git or Github and couldn't deliver as I expected, Hence this article is a help guide them/you a beginner at either or both. This article assumes you're using Git as a Distributed Version control system, Github as a Git repository hosting service and have Git bash installed.
Let's get to it
You've got a task assigned to you and you know what to do codewise, the problem is getting your code on GitHub so everyone can see what an awesome job you've done.
Firstly you should clone the Repo you are working on. This can be done by navigating to the main page of the repository you're working on and clicking the green Clone or download button.
You can either clone the repository using HTTPS, under "Clone with HTTPS" or clone the repository using an SSH key, including a certificate issued by your organization's SSH certificate authority, click Use SSH.
git clone <repo link>
Problem? Is the Repo empty, you can manually copy the repository page's URL from your browser and skip to the next step
Navigate to the directory where you cloned the repo
Create a new branch, it's advisable that you create a branch for each feature/task you work on
git checkout -b 'branch-name'
Before starting anything you should run
This way you can get all packages added to the project on your local Problem? This probably caused by Node not being installed. Install node to be able to access npm.
This is the part where you add in code your magic code, your awesome implementation of the task. Yep, this is the part where your mind-blowing code that WORKS goes.
So we want Git to include the updates to a particular file in the next commit
Let's Save the changes to the local repository
You should pull the latest changes to the repo before pushing
Let's get our code from our local to remote by pushing the code
git push --set-upstream origin <branch name>
Head over to the main page of the repo and you should see a popup
Click the button to compare and create a Pull Request and you should see
Create a Pull Request and you're good to go. For a better understanding of git/github visit link