DEV Community

Cover image for Simple Git and GitHub Commands for Beginners
Mahmud R. Farhan
Mahmud R. Farhan

Posted on

Simple Git and GitHub Commands for Beginners

Git and GitHub may seem a bit intimidating at first, but there’s no need to worry! Here’s a handy list of essential commands to help you smoothly get started. 💻✨

1. Setup Your Identity

Before doing anything, let Git know who you are:

git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"
Enter fullscreen mode Exit fullscreen mode

2. Initialize a Repository

Start tracking your project:

git init
Enter fullscreen mode Exit fullscreen mode

3. Check the Status

Know what’s happening in your repository:

git status
Enter fullscreen mode Exit fullscreen mode

4. Add Files to Staging Area

Prepare your changes for a commit:

git add .
Enter fullscreen mode Exit fullscreen mode

5. Commit Your Changes

Save your progress with a message:

git commit -m "Initial commit"
Enter fullscreen mode Exit fullscreen mode

6. Connect to a Remote Repository

Link your local repository to GitHub:

git remote add origin https://github.com/yourusername/your-repo.git
Enter fullscreen mode Exit fullscreen mode

7. Push Your Code to GitHub

Upload your changes:

git push -u origin main
Enter fullscreen mode Exit fullscreen mode

8. Clone a Repository

Copy an existing repository to your local machine:

git clone https://github.com/username/repository.git
Enter fullscreen mode Exit fullscreen mode

9. Pull Latest Changes

Stay updated with the remote repository:

git pull origin main
Enter fullscreen mode Exit fullscreen mode

10. View Commit History

Check what’s been done:

git log
Enter fullscreen mode Exit fullscreen mode

Pro Tip 💡

If you're unsure, git status is your best friend!


With these commands, you’re ready to start your Git and GitHub journey. Happy coding! 🚀


Follow for more!

Top comments (0)