Mastering GitHub Basics: A Command Line Guide
GitHub, the world's leading platform for version control and collaboration, offers a powerful command line interface (CLI) for efficient workflows. This guide will walk you through the basics of GitHub command line, ensuring you're well-equipped to navigate and manage your repositories like a pro.
Getting Started: Installation and Configuration
Before diving into GitHub command line, ensure you have Git installed on your local machine. You can download and install it from the official Git website. Once installed, configure Git with your name and email using the following commands:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
Setting Up a GitHub Repository
To start using GitHub command line, create a new repository on GitHub.com, then clone it to your local machine using the following command:

git clone https://github.com/yourusername/your-repo-name.git
Now, navigate into your local repository:
cd your-repo-name
Understanding GitHub Command Line Workflow
The GitHub command line workflow revolves around three main stages: staging, committing, and pushing. Let's explore each stage with practical examples.
Staging Changes
First, make some changes to your local files. To see the status of your changes, use the git status command. To stage a file, use:

git add your-file-name
To stage all changes in the current directory, use:
git add .
Committing Changes
Once you've staged your changes, commit them with a meaningful commit message:
git commit -m "Your commit message"
Pushing Changes
Finally, push your committed changes to the remote repository:

git push origin main
Or, if you're using the master branch:
git push origin master
Branching and Merging
GitHub command line allows you to create, switch, and merge branches effortlessly. To create a new branch:
git checkout -b new-branch
To switch to an existing branch:
git checkout existing-branch
To merge a branch into the current branch:
git merge branch-to-merge
Resolving Conflicts
When merging branches, you may encounter merge conflicts. GitHub command line helps you resolve these conflicts by marking the conflicting sections in your files. Edit the files to resolve the conflicts, then stage and commit the resolved changes:
git add resolved-file
git commit -m "Resolved merge conflict"
Tracking Changes with Logs
To view the commit history of your repository, use the git log command. You can customize the output using various flags, such as:
--oneline: Display one-line commit messages--graph: Display a graph of the commit history--all: Display commits from all branches
For example, to display a graph of one-line commit messages from all branches:
git log --oneline --graph --all
Conclusion
Mastering GitHub command line allows you to streamline your workflow, collaborate more effectively, and gain a deeper understanding of version control. With these basics under your belt, you're well-equipped to tackle more advanced GitHub command line topics and become a proficient Git user.






















