How to use GitHub & Git Commands Tutorial

How to use GitHub & Git Commands Tutorial

Git Commands Tutorial

GitHub and Git are powerful tools that revolutionize the way developers collaborate, track changes, and manage versions of their code. Whether you're a seasoned developer or just starting your coding journey, mastering GitHub and Git commands is essential for efficient and effective software development. In this article, we will delve into the world of GitHub and Git commands, equipping you with the knowledge and expertise needed to accelerate your development workflow and collaborate seamlessly with others. Get ready to unlock the full potential of these tools and elevate your coding game.

  1. Understanding Git:

Git is a distributed version control system that allows developers to track changes in their codebase, create branches, merge changes, and collaborate with others. Here are a few essential Git commands to get you started:

  • git init: Initialize a new Git repository in your project directory.
  • git add <filename>: Add a file to the staging area.
  • git commit -m "commit message": Create a new commit with the changes in the staging area.
  • git status: View the status of your repository and see which files have changed.
  • git log: View the commit history of your repository.
  1. Collaborating with GitHub:

GitHub is a web-based platform that leverages Git for seamless collaboration and code sharing. Here are a few key GitHub commands and concepts:

  • Cloning a Repository: Use git clone <repository URL> to create a local copy of a remote repository on your machine.
  • Forking a Repository: Forking allows you to create a personal copy of someone else's repository on GitHub.
  • Branching: Use git branch to create a new branch and git checkout <branch name> to switch to a different branch.
  • Pull Requests: Submitting a pull request allows you to propose changes to a repository and collaborate with other developers.
  • Collaborating: You can add collaborators to your repository, manage access permissions, and work together on projects.
  1. Working with Remote Repositories:

Git allows you to work with remote repositories hosted on platforms like GitHub. Here are a few essential commands for working with remote repositories:

  • git remote add origin <repository URL>: Connect your local repository to a remote repository.
  • git push origin <branch name>: Push your local changes to the remote repository.
  • git pull origin <branch name>: Pull changes from the remote repository to your local repository.
  • git fetch: Fetch changes from the remote repository without merging them.
  • git merge: Merge changes from a different branch into your current branch.
  1. Advanced Git Techniques:

As you become more comfortable with Git and GitHub, you can explore advanced techniques to streamline your workflow. Here are a few examples:

  • Rebasing: Use git rebase to modify the commit history and incorporate changes from one branch into another.
  • Git Hooks: Git hooks allow you to automate actions and run custom scripts at specific points in the Git workflow.
  • Gitignore: The .gitignore file allows you to specify files and directories that Git should ignore.
  1. GitHub Workflows:

GitHub provides various workflows and features to enhance collaboration and streamline development. Here are a few notable examples:

  • GitHub Actions: Automate your development workflows by creating custom actions and workflows.
  • GitHub Projects: Organize your work into Kanban-style boards to track tasks, issues, and milestones.
  • Issue Tracking: Use GitHub issues to report bugs, suggest enhancements, and track progress.


Mastering GitHub and Git commands empowers you to work collaboratively, track changes, and streamline your development workflow. By understanding the fundamentals of Git, leveraging GitHub's collaboration features, and exploring advanced techniques, you can maximize your productivity and deliver high-quality code.

Embrace the power of GitHub and Git, and immerse yourself in the vibrant developer community that surrounds these tools. Continuously learn and improve your skills by exploring online resources, attending webinars, and engaging with fellow developers. With dedication and practice, you'll become a proficient user of GitHub and Git, accelerating your development journey and achieving new heights in your coding endeavors.


Set configuration values for your username and email
git config –global YOUR NAME
git config –global YOUR EMAIL

Set default branch to main
git config –global init.default branch main

Get help on a command
git help COMMAND
git COMMAND -h

Initialize a new git repository
git init

Clone a repository

Add a file to the staging area
git add FILE

Add all file changes to the staging area
git add –all
git add -A
git add .

Check the unstaged changes
git diff

Commit the staged changes
git commit -m “MESSAGE”

Reset staging area to the last commit
git reset

Check the state of the working directory and the staging area
git status

Remove a file from the index and working directory

Rename a file
git mv (OLD NAME) (NEW NAME)

List the commit history
git log

List all the local branches
git branch

Create a new branch
git branch BRANCH NAME

Rename the current branch
git branch -m NEW BRANCH NAME

Delete a branch
git branch -d BRANCH NAME

Switch to another branch
git switch BRANCH NAME

Merge specified branch into the current branch
git merge BRANCH NAME

Create a connection to a remote repository
git remote add (NAME) (REPOSITORY URL)

Push the committed changes to a remote directory
git push (REMOTE) (BRANCH)

Download the content from a remote repository
git pull REMOTE

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button