The reason I came up with the idea of writing this story is that I have been leading a community in my campus and have already organized Git & GitHub workshops but after some polls and survey turn out that most of the students in my university(mostly from fresher and sophomore year) don’t even know the basic git commands and GitHub workflow. 🤷🏻♂️
So, this post is basically for newbie developers who struggle in understanding Git and GitHub & also for those who are sitting at the hackathons building the projects and they just want to upload their project for submission without wasting time in learning Git and GitHub from scratch that’s why I’m going to keep it easy peasy.😉
I will not be diving deep into Git/GitHub but at the end of the post you’ll be easily able to:
- Push your project from local system to your GitHub profile
- Work on someone else’s project on GitHub and create a Pull Request
Before moving on you should have created your GitHub account and Installed Git on your local system. Creating a GitHub account is same as creating an account on any website which is followed by mandatory email verification. If you’re installing git for the first time in your local system then follow below mentioned steps else skip this part.
- Download git setup from the website https://git-scm.com/downloads
- Install git from the setup(keep clicking next and select default options till the installation completes)
- Now you can check whether you have successfully installed git on your system or not by entering this command on command prompt
- Once successfully installed, you have to set up your username and email(the one you used to create GitHub account) and this is important because git commit uses this information. This is a one-time setup:
git config --global user.name "John Doe"
git config --global user.email email@example.com
- After setting up username and email you’re good to go and remember git will ask you for your GitHub credentials when you’ll push for the first time.
So Let’s begin!
Pushing project from local system to GitHub
- Creating a git repository on your system
Suppose you have been working on the development of a website and now the website is completely ready and you want it to push on your GitHub account. So, the first thing you need to do is to make convert your project folder into a git repository then only you’ll be able to perform all the git commands on that folder. To do this you need to open the command prompt and the path needs to be of the project folder in cmd.
example: my website is in D drive inside the folder named fun then in command prompt it should show like this D:\fun\website>
And now the final step to initialise a git repository
D:\fun\website> git init
- Link repository on GitHub(remote repo) and repository on the local system
Go to GitHub profile and create a new repository with any name you wish, add repository description, make it public or private, and don’t Initialize this repository with a README. Now copy the https link given in the Quick Setup Section.
Go to your website folder-> Open CMD there ->and type
git remote add origin <paste the link copied> and enter.
ex. git remote add origin https://github.com/withshubh/test.git
Voila! nothing happens that means you just linked your local repo to GitHub repo.
- Pushing local repository to the remote (GitHub) repository
On the command prompt, type these commands in a sequence:
- git add . (this command basically add all the files in the website folder to staging area)
- git commit -m “first push” (this command is used to save changes to the local repository and the -m is used to add a message with that commit which helps you remember what changes you made when you made this commit)
- git push origin master (this command is going to upload files/changes made in the local repository to the remote repository which is on your GitHub)
- At the last step, you may be asked for your GitHub credentials if you’re using git for the first time. You can check your GitHub repository now It must contain all the files from your local repository.
Congratulations! you just learned how to push local repository on your GitHub.🤩
Work on someone else’s project on GitHub and create a Pull Request
- Fork a repository
Find some interesting project on GitHub on some organisation or some Developer’s GitHub profile. Open the repository:
let’s take an example repository https://github.com/withshubh/Labyrinth-new
When you’ll visit the repository you’ll see three buttons on the top right of the screen: Watch, Star & Fork.
Click on Fork and it will create a copy of the original repository in your GitHub Profile.
- Edit project, make improvements or fix bugs!
Now as you’ve got the copy of the original project in your own GitHub profile you can edit whatever you want. There are two ways you can work on this project:
1. by editing files on the GitHub itself!
Just open file you want to work and make changes using GitHub’s editor and commit the changes.
2. by cloning this forked repository on your local system
When you open a repository in GitHub you see a green button which says clone or download. Just click on that button and copy the URL given. On your local system open command on the location(path in cmd) where you want the repository to be cloned and type the command:
git clone <URL> and enter
ex- git clone https://github.com/withshubh/Labyrinth-new
And you’ll notice that git has started to download files on local system. Once all the files are downloaded(cloned) to the local system you can work on the project and make changes according to you. Once done, use the steps mentioned in “Pushing local repository to the remote (GitHub) repository” at the top of this post.
- Creating Pull Request
After pushing changes from the local repository to your forked GitHub repository. On your GitHub, you’ll notice the commit you made. Now click on the New Pull Request button. You’ll notice that GitHub compares your head repository(cloned repo) and base repository(original repo) and says ‘able to merge’ if there is no merge conflict then click on Create Pull Request, It will ask you to enter the title of your pull request and the details of your pull request when you’ve filled the details click on the create pull request button on the bottom.
Congratulations! You just made your first Pull Request ✨
P.S: This story is for beginners and I have not explained the jargons and concepts.