The complete beginners guide : Getting started with Git & GitHub

In this article you will learn about git, GitHub and how to make your first PR(Pull Request) use them 👇

Are you still confused! looking to get started with Git & GitHub. Are you still getting errors while pushing your code. Are you want to contribute in open source

❝The power of Open Source is the power of the people. The people rule❞

This article will get you up and running with the basics. There’s a lot of stuff to learn if you want to use Git and GitHub like a pro, of course. You can go way beyond this introductory information! We’re going to leave the next-level stuff for another time, though.

Let’s get started!

The complete beginners guide : Getting started with Git & GitHub

What is Git & GitHub?

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Git is easy to learn and has a tiny footprint with lightning fast performance. It outclasses SCM tools like Subversion, CVS, Perforce, and ClearCase with features like cheap local branching, convenient staging areas, and multiple workflows.

❝ People say that if you’re still angry at 52, you’re not an angry young man, just a grumpy old git❞

GitHub is a web-based interface that uses Git. It is one of the world’s largest community of developers. It’s an intricate platform that fosters collaboration and communication between developers.

GitHub has a number of useful features that enable development teams to work together on the same project and easily create new versions of software without disrupting the current versions.

With GitHub, you can collaborate and work on projects with others anywhere in the world.

Of course, that’s only scratching the surface, because when it comes to the question “What is GitHub?” the answer is all about what it can do for you

Any fool can write code that a computer can understand. Good programmers write code that humans can understand

Let’s Start :

There are a ton of ways to use Git and GitHub, but getting started with GitHub doesn’t have to be overwhelming. You don’t need to be some kind of master coder or anything. You can even do the most important things right on the GitHub website!

That being said, it’s a good idea to find your terminal and get just the tiniest bit comfortable with it. Terminal commands make things so much faster! I’ll definitely show you how to get started using the GitHub website. I’ll also show you some terminal commands that you might want to use to make your life just a little bit nicer.

Any time you see a < > command in this article, replace it with them your own information.

Let’s say, you see git add <filename> That means you have to replace <filename> with your file name which you want to upload on GitHub. like “java.md”.

Before moving further lets took an look on important terminal commands that’s you really need to getting started.

git clone
git status
git add
git commit -m "enter your commit here..."
git push

That’s it! Those are the big ones! If you have a handle of those, you’re good to go. You can start working on your projects immediately!

We’ll also talk about

git init
git branch
git merge
git checkout

Setting up environment

Step 1 :- Sign up and Installation!

Go to GitHub and sign up for your account. You can also work without installing git, but if you work on local then you have to install git in you local computer. If you don’t like git too much, you can also work with Terminal/Command line.

To install git on your local computer/ laptop follow the given instruction :-

1. On Windows :

2. On Linux :

  • If you’re Fedora(or any closely-related RPM-based distribution) you can use dnf:
$ sudo dnf install git-all
  • If you’re a Ubuntu user, you can use apt:
$ sudo apt install git-all

3. On Mac :

  • There are several ways to install Git on a Mac. In fact, if you’ve installed XCode (or it’s Command Line Tools), Git may already be installed. To find out, open a terminal and enter git --version.
  • If you don’t have it installed already, it will prompt you to install it.

Now you’re ready to start using Git on your computer!

Are you ready!

Make it work, make it right, make it fast.

Now let’s talk about commands which we mentioned above 👆 :

  1. git clone :- git clone is a git command line utility which is used to target an existing repository and create a clone, or copy of the target repository.

git clone https://github.com/<your-username> <repository-name>.git/

2. git status :- git status command basically lets you see which changes have been staged, which haven’t, and which files aren’t being tracked by Git. Status output does not show you any information regarding the committed project history. For this, you need to use git log.

git status

3. git add :- The git add command adds a file to the Git staging area. This area contains a list of all the files you have recently changed. Your repository will be updated the next time you create a commit with your changes.

Therefore, running the git add command does not change any of your work in the Git repository.

👉 There are many syntax to use git add command. I listed them 👇 use according to your need.

  • git add <file-name> :- This commands add specific files/folders which you want to add.
  • git add README.md :- This add command adds the file README.md
  • git add . :- This command adds every change we made to files and folders from our repository.

4. git commit -m "Enter your commit here...." :- Takes the staged snapshot and commits it to the project history. Combined with git add, this defines the basic workflow for all Git users.

5. git push :- The git push command is used to upload local repository content to a remote repository.

👉 There are many syntax to use git push command. I listed them 👇 use according to your need.

  • Default :- git push origin main <branch-name
  • Amended force push :- git push --force origin main
  • Deleting a remote branch or tag :- git branch -D <branch-name> git push origin :branch_name .
  • The 👆 will delete the remote branch named branch_name passing a branch name prefixed with a colon to git push will delete the remote branch.

👉 These are the common commands which used while uploading or pushing any project or repository to GitHub using or git base terminal .

Now let’s discuss some more commands 😍

6. git init :- git init is one way to start a new project.

7. git branch :- The git branch command lets you create, list, rename, and delete branches. It doesn’t let you switch between branches or put a forked history back together again.

👉 For this reason, git branch is tightly integrated with the git checkout and git merge commands.

👉 Common syntax used for git branch are listed 👇

  • git branch --list :- list all of the branch in your repository.
  • git branch <branch_name> :- Create a new branch called <branch_name>. This does not check out the new branch.
  • git branch -d <branch_name> :- Delete the specified branch_name. This is a “safe” operation in that Git prevents you from deleting the branch if it has unmerged changes.
  • git branch -D <branch_name> :- Force delete the specified branch, even if it has unmerged changes.

This is the command to use if you want to permanently throw away all of the commits associated with a particular line of development.

  • git branch -r <branch_name> :- Rename the current branch to <branch_name>
  • git branch -a :- List all remote branches.

So, far we have learned the basics, If anyone have any query or wants full explanation of any commands just dm me on my social media accounts.

How to create a Pull Request in GitHub?

You shit with you laptop/computer and doing some work. suddenly your mind blows and you think Aaquib show me a project and upload it on GitHub. You like that project and want to contribute in it. You know the Basic of Git & GitHub and don’t know how to make a PR(Pull Request).

In this section i will show you how you can make a PR on a Project and contribute to it. To make your first PR you can contribute to my Awesome-Readme-Profiles

👉 To contribute to above or any project the first step you have to do is fork the the project. To fork the Project/Repository click on fork button. which is on the right topmost corner.

Click on fork button to fork the repository

after fork you have to make a clone of the Project/Repository .

👉 To clone the Repository, click on code and copy the HTTPS .

copy the HTTPS to clone the repo.

👉 Go to Desktop and open Git Bash and clone the repository

git clone https://github.com/<your-user-name>/<repository-name>

👉 wow you have the copy of the repository in laptop.

👉 Navigate to the project directory 📁.

cd <repository-name>

I suggest you to make the changes in new branch rather than the main/master branch. so, your code don’t conflict while you make your PR.

👉 To make the new branch see the code ☺️

git checkout -b branch-name

👉 To make changes you have to open your repository in your favorite editor mine is vs code 😍

code .

👉 Now, made the changes in your repository and save it.

👉 Before you push the changes in your forked repository you have to check the status that changes you have made are changed or not.

👉 to check the status copy the code or type

git status

👉 we have to add the changes we have make in our fork repository. To add the changes copy the code or type

git add .

👉 it add all the changes to your forked repository. 👆

👉 now, you have to commit all the changes you have made. to commit the changes copy the code or type

git commit -m "your commit begins here..."

👉 you have tracked your changes. here the last step you do is to push the code.

👉 to push the code copy the code or type

git push origin <branch-name>

Congratulation 🎉 you successfully pushed the code.

👉 Go to your forked GitHub repository. you see compare & Pull Request option as show in image. to make a PR just clock on compare and pull.

click on compare & pull request button to make PR

👉 after click on compare & pull request button you will be redirected to open a pull request page. as shown below

click create pull request button to create PR

👉 just type what about the PR and click on Create pull request button to make a PR.

Congratulations 🎉 finally you made your first Pull Request.

If anyone have any query or wants more explanation of any commands or anything just dm me on my social media accounts. I will reply you as fast as i can

Thanks for reding this blog. If you like this Blog, don’t forget to clapped. or show some more love share this blog with your friends.

JUST GO FOR IT!!!

--

--

--

Improving the world w/ better education…

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aaquib Developer

Aaquib Developer

Improving the world w/ better education…

More from Medium

TOP Git Commands, Every Programmer Must know

Git Basics For Beginners #1

API Integrations

Getting Familiar with the Git Terminology