Most commonly used Git commands

Most commonly used Git commands

Hello fellow developers🙋‍♂️,

I'm sure you're familiar with GitHub. Today, I will be providing a comprehensive list of the most commonly used Git commands that you can seamlessly incorporate into your workflow, tailored to your specific needs. So, let's get started!

Here are some of the most commonly used Git commands for GitHub:

Set Username:

git config --global user.name "YourUserName"

Replace "YourUserName" with your desired username.

Set Email:

git config --global user.email "youremail@example.com"

Clone a Repository:

git clone https://github.com/username/repo.git

Pull Changes from Remote:

git pull origin master

Add Changes to Staging:

git add filename   # Add a specific file
# or
git add .   # Add all changes

Commit Changes:

git commit -m "Your commit message"

Push Changes to Remote:

git push origin branchname

List and Create Branches:

git branch   # List all branches
git branch branchname   # Create a new branch

Delete a Branch:

git branch -d branchname

Switch Branches:

git checkout branchname   # Switch to an existing branch
git checkout -b newbranchname   # Create and switch to a new branch

Merge Branches:

git merge branchname

Check Repository Status:

git status

View Commit History:

git log

Manage Remote Repositories:

git remote -v   # List remote repositories
git remote add origin https://github.com/username/repo.git   # Add a new remote

Fetch Changes from Remote:

git fetch origin

That is it for now. These commands cover the basics of interacting with a GitHub repository using Git. As you become more familiar with Git and GitHub, you may explore additional commands and more advanced features to enhance your development workflow.

If you found this article helpful and insightful, why not stay updated with more valuable content? Consider subscribing to my weekly newsletter, where every Friday, I delve deeper into essential concepts, share my latest discoveries, and provide valuable resources to fuel your growth and success.

Wishing you a fulfilling and joyous coding adventure! Happy coding!😊😊