• About Us
  • Announce
  • Privacy Policy
  • Contact us
MasterTrend News
  • HOME
    • BLOG
  • Tutorials
  • Hardware
  • Gaming
  • Mobile
  • Security
  • Windows
  • IA
  • Software
  • Networks
  • What's new
  • en_USEnglish
    • es_ESSpanish
    • pt_BRPortuguese
    • fr_FRFrench
    • it_ITItalian
    • de_DEGerman
    • ko_KRKorean
    • jaJapanese
    • zh_CNChinese
    • ru_RURussian
    • thThai
    • pl_PLPolish
    • tr_TRTurkish
    • id_IDIndonesian
    • hi_INHindi
    • arArabic
    • sv_SESwedish
    • nl_NLDutch
No result
See all results
  • HOME
    • BLOG
  • Tutorials
  • Hardware
  • Gaming
  • Mobile
  • Security
  • Windows
  • IA
  • Software
  • Networks
  • What's new
  • en_USEnglish
    • es_ESSpanish
    • pt_BRPortuguese
    • fr_FRFrench
    • it_ITItalian
    • de_DEGerman
    • ko_KRKorean
    • jaJapanese
    • zh_CNChinese
    • ru_RURussian
    • thThai
    • pl_PLPolish
    • tr_TRTurkish
    • id_IDIndonesian
    • hi_INHindi
    • arArabic
    • sv_SESwedish
    • nl_NLDutch
No result
See all results
MasterTrend News
No result
See all results
Start Tutorials

10 Basic Git Commands Every Developer Needs 🖥️

MasterTrend Insights by MasterTrend Insights
April 3, 2025
in Tutorials
Reading time:7 min read
To To
0
10 Basic Git Commands to Get You Started
4
SHARED
11
Views
Share on FacebookShare on Twitter

Contents

  1. 10 Basic Git Commands to Protect Your Code 🔒
  2. 1 Clone an Existing Repo
  3. 2 Create a New Repo
  4. 3 Create a Branch to Collaborate
  5. 4 Switch between Branches
  6. 5 Check Git Status
  7. 6 Commit Change Sets
  8. 7 Undo Changes
  9. 8 Upload All Your Local Changes
  10. 9 Recover All Changes
  11. 10 Merge It All Together

10 Basic Git Commands to Protect Your Code 🔒

Spending another all-nighter trying to recover lost code changes? You're not alone. That's why millions of developers rely on Git, the world's leading version control system, to track every change and protect their work. Here's a rundown of the commands you'll use most. 🚀

Si sos nuevo en Git, empecemos con una refrescada. Un repositorio de Git (o repo en corto) contiene todos los archivos del proyecto y toda la historia de revisiones. Un repo tiene commits, que son los que se usan para registrar los cambios en el repo, y cada commit tiene un breve mensaje que el usuario escribe para indicar qué cambios realizó. Git también puede help manage conflicts (for example, if two people edit the same line of code) before merging. To learn more about installing Git on Windows, click here.

1 Clone an Existing Repo

The first command we can start with is git clone, which is a command that connects and download a copy from an existing repository to your local machine. Usually, the existing repository is located remotely, such as on GitHub or GitLab.

First, go to a repo and click the green dropdown menu that says “Code,” then the copy to clipboard icon next to the GitHub repository URL, which will clone it using the Web URL. This is the easiest method and clones using HTTPS:

Number of arrows showing the option to clone repositories over HTTPS on GitHub.

Then, run the following command with the URL you just copied:

git clone https:
Repo clone completed message in Git Bash CLI.

Once the repo is cloned, you should have a local copy of it on your machine. 👍

If you get an error saying "fatal: repository not found," check the URL. If it's a private repo, you may need permissions to access it.

2 Create a New Repo

If you want to create a new Git repository instead of cloning an existing one, run git initThis initializes the repository in the specified directory, giving it a path. So it's ideal for new or untracked projects that you want to start using Git.

First, make sure you are in the correct folder before running the command:

git init
Empty repo error message in Git init commands.

3 Create a Branch to Collaborate

A branch in Git is a version of your repository, so multiple people can work on it simultaneously. In other words, it's an independent line of development within a repo. Typically, there are multiple branches in a repo.

To create a local branch, run the following command:

git branch branch-name

To list all your branches, run:

git branch

To delete a branch:

git branch -d branch-name
When you delete a branch, it is sometimes necessary to force the deletion. You just have to capitalize the -D, So: git branch -D branch-name

4 Switching between Branches

The command git checkout It is one of the most used, mainly to switch between branches, but it can also be used to review files and commits.

To switch between branches and check them out in your local directory:

git checkout branch-name

For newer versions of git, you can run:

git switch branch-name

For the above commands to work, the branch you are switching to must exist locally, and any changes to your current branch must be committed or saved first.

Shortcut command to create and switch branches at the same time: git checkout -b branch-name

5 Check Git Status

This is another common command, which can tell you different information about the current branch, such as whether the current branch is up to date or not, if there is anything left to commit or push, and if there are any files that were modified or deleted.

git status

This is what the output should look like if there are no changes to be made:

Git status command on the command line with output saying nothing to commit, clean working tree.

6 Commit Change Sets

This may be the most used Git command. When we're ready to save our work, perhaps after a specific task or issue, we can use git commitThis essentially captures a snapshot of the changes currently being prepared in the project.

You also need to write a short, clear commit message so you and other developers know about the changes. Don't forget to surround it with quotation marks.

git commit -m "confirmation message"
Git commit Just save your changes locally. You still need to push them to a remote repo.

7 Undo Changes

The command git revert allows you eliminate all the changes a single commit has made to your local repo. For example, if a previous commit added a file called ReadMe.md to the repo, a git revert In that commit, the ReadMe.md will be removed from the repo. A new commit will also be created to reflect this change.

All you need to do is run git revert followed by the commit ID:

git revert commit-id

If you've made a lot of commits and you're not sure where the commit ID is, you can identify the commit by running the command git log. Copy the commit ID and run the command git log with the commit ID.

Git log command in CLI showing previous commits and commit IDs.
Do not confuse git revert with git resetThe latter will undo every change that occurred since a given commit and change the commit's history. This isn't ideal if other people are working on the same branch.

8 Upload All Your Local Changes

Once you've finished making all your changes and committing them, you'll want to push your local changes to the remote repo. Pushing is the act of transferring these changes and commits from your local machine to the remote repository. You can specify which branch you want to send the changes to.

git push origin master

The above command pushes the changes to the master branch (master is usually considered the main branch, but "main" is also commonly used). If master doesn't work, try with main.

It is recommended to run git status before uploading your changes.

9 Recover All Changes

This is a command I use when I return to a project and need to retrieve all the new changes made to the master branch (whether through my merge or from other developers) that exist remotely. In other words, it's a command you use when you want to get updates from the remote repository.

git pull origin main

As before, yes master doesn't work, try with main. Since this command combines the functions of git fetch and git merge, instantly applies the latest modifications to your local repository (git merge) after retrieving updates from the remote repository (git fetch). You can learn more about pull requests in Git.

10 Merge It All Together

Finally, once you're done working on your branch and everything is working correctly, the last step is to merge the branch into the main branch (usually dev or master, but check the repo).

You can do this by running the command git merge. First you should execute git fetch to update your branch local, and then make your merge:

git merge branch-name
Make sure you are on the branch you want to merge into your remote master branch.

In the end, learning Git is like riding a bike: once you start, it only gets easier with every push! 🚴‍♂️💻

Share this:
FacebookLinkedInPinterestXRedditTumblrBlueskyThreadsShareChatGPTClaudeGoogle AIGrok
Tags: EvergreenContentTechtipsWindowsTips
Previous Publication

AI Features in Chrome 🔥: Transform Your Browsing

next post

Kernel Verification Failures: Fix It Now! 🔥

MasterTrend Insights

MasterTrend Insights

Our editorial team shares a deep-dive analysis, tutorials and recommendations for getting the most out of your devices and digital tools.

RelatedPublications

RESULT_CODE_HUNG - Person using laptop with Chrome error "Aw, Snap!" (RESULT_CODE_HUNG), showing a 1-click solution that fixes Google Chrome and prevents it from freezing.
Tutorials

RESULT_CODE_HUNG: One-click solution that fixes Chrome 🚀

November 19, 2025
62
Rename PC in Windows 11: Settings screen showing "Change Computer Name", guide with 3 quick methods: CMD, PowerShell and Settings.
Tutorials

Rename your PC: done in 10 seconds, goodbye weird names 🔥

November 19, 2025
94
GIMP Stable Boy - User at a desk working in GIMP; screen shows GIMP Stable Boy plugin tutorial in Spanish for free generative fill-an open‑source Adobe alternative.
Tutorials

GIMP Stable Boy: Avoid Adobe and create magic for free 💥🚀

November 18, 2025
63
Disable autocorrect on iPhone: WhatsApp screen with keyboard open, steps to remove keyboard autocorrect on iOS.
Tutorials

Turn off autocorrect NOW: write freely in 1 min ⏱️🔥

November 6, 2025
79
Steam Damaged Update Files - How to fix the Steam error "damaged/corrupted update files"; Steam logo on dark background, step-by-step guide and solution.
Tutorials

Steam Corrupted Update Files: Fix in 2 min ⏳

November 6, 2025
90
Windows 11 preview on laptop: File Explorer in dark mode with folder and magnifying glass; woman using her PC on a home desk.
Tutorials

Windows 11 Preview: Mac-Style Quick Look with Space ⏱️

October 13, 2025
80
next post
BSOD 'Kernel Security Check Error' 😱. Find out how to fix it quickly and easily in just a few minutes.

Kernel Verification Failures: Fix It Now! 🔥

5 3 votes
Article Rating
Subscribe
Access
Notify of
guest
guest
0 Comments
Oldest
Newest Most voted
Online Comments
See all comments

Stay Connected

  • 976 Fans
  • 118 Followers
  • 1.4 k Followers
  • 1.8 k Subscribers

Do not miss the latest in technology and gaming.
Tips unique, practical guides and analysis every day.

Subscription Form
  • Trends
  • Comments
  • Last
How to add clock on the Windows desktop 11: ¡3 tricks infallible!

How to add clock on the Windows desktop 11: Get more in minutes! ⏱️

1 May 2025
How to save game in REPO

How to save game in REPO 🔥 Discover the secret to not losing progress

7 July 2025
12 Best Alternatives to Lucky this program for Android

Alternatives to Lucky this program: the 12 apps best and easy! 🎮⚡

13 November 2025
🖥️ How to open 'Devices and printers' in Windows 11: 4 simple steps

🌟 How to open ‘Devices and printers’ in Windows 11: ¡Amazing trick!

November 20, 2025
Features of Gmail on Android: Save time with 5 tips

Features of Gmail in Android: you 5 tricks you did not know! 📱✨

12
Repair of motherboards - Repair MotherBoards

Repair of motherboards of Laptops

10
Install Windows 11 Home without Internet

Install Windows 11 Home without Internet

10
How to backup drivers in Windows 11/10 in 4 steps!

How to backup drivers in Windows 11/10 It Prevents errors! 🚨💾

10
RESULT_CODE_HUNG - Person using laptop with Chrome error "Aw, Snap!" (RESULT_CODE_HUNG), showing a 1-click solution that fixes Google Chrome and prevents it from freezing.

RESULT_CODE_HUNG: One-click solution that fixes Chrome 🚀

November 19, 2025
Secret Fire Gate in Doom The Dark Ages: First-person view with a gate covered in flames blocking the way, guide to opening it.

Secret Fire Door: Hidden Valve, enter now⚠️

November 19, 2025
Remove Hotcleaner.com in one click and protect Chrome: woman using PC with Google Chrome logo and security warning on screen.

Hotcleaner.com: Discover and remove the extension 🔥🔧

November 19, 2025
Rename PC in Windows 11: Settings screen showing "Change Computer Name", guide with 3 quick methods: CMD, PowerShell and Settings.

Rename your PC: done in 10 seconds, goodbye weird names 🔥

November 19, 2025

Recent News

RESULT_CODE_HUNG - Person using laptop with Chrome error "Aw, Snap!" (RESULT_CODE_HUNG), showing a 1-click solution that fixes Google Chrome and prevents it from freezing.

RESULT_CODE_HUNG: One-click solution that fixes Chrome 🚀

November 19, 2025
62
Secret Fire Gate in Doom The Dark Ages: First-person view with a gate covered in flames blocking the way, guide to opening it.

Secret Fire Door: Hidden Valve, enter now⚠️

November 19, 2025
112
Remove Hotcleaner.com in one click and protect Chrome: woman using PC with Google Chrome logo and security warning on screen.

Hotcleaner.com: Discover and remove the extension 🔥🔧

November 19, 2025
49
Rename PC in Windows 11: Settings screen showing "Change Computer Name", guide with 3 quick methods: CMD, PowerShell and Settings.

Rename your PC: done in 10 seconds, goodbye weird names 🔥

November 19, 2025
94
MasterTrend News logo

MasterTrend Info is your source of reference in technology: discover news, tutorials, and analysis of hardware, software, gaming, mobile, and artificial intelligence. Subscribe to our newsletter and don't miss any trend.

Follow us

Browse by Category

  • Gaming
  • Hardware
  • IA
  • Mobile
  • What's new
  • Networks
  • Security
  • Software
  • Tutorials
  • Windows

Recent News

RESULT_CODE_HUNG - Person using laptop with Chrome error "Aw, Snap!" (RESULT_CODE_HUNG), showing a 1-click solution that fixes Google Chrome and prevents it from freezing.

RESULT_CODE_HUNG: One-click solution that fixes Chrome 🚀

November 19, 2025
Secret Fire Gate in Doom The Dark Ages: First-person view with a gate covered in flames blocking the way, guide to opening it.

Secret Fire Door: Hidden Valve, enter now⚠️

November 19, 2025
  • About Us
  • Announce
  • Privacy Policy
  • Contact us

Copyright © 2025 https://mastertrend.info/ - All rights reserved. All trademarks are property of their respective owners.

We've detected you might be speaking a different language. Do you want to change to:
es_ES Spanish
es_ES Spanish
en_US English
pt_BR Portuguese
fr_FR French
it_IT Italian
ru_RU Russian
de_DE German
zh_CN Chinese
ko_KR Korean
ja Japanese
th Thai
hi_IN Hindi
ar Arabic
tr_TR Turkish
pl_PL Polish
id_ID Indonesian
nl_NL Dutch
sv_SE Swedish
Change Language
Close and do not switch language
No result
See all results
  • en_USEnglish
    • es_ESSpanish
    • pt_BRPortuguese
    • fr_FRFrench
    • it_ITItalian
    • de_DEGerman
    • ko_KRKorean
    • jaJapanese
    • zh_CNChinese
    • ru_RURussian
    • pl_PLPolish
    • id_IDIndonesian
    • tr_TRTurkish
    • hi_INHindi
    • thThai
    • arArabic
    • sv_SESwedish
    • nl_NLDutch
  • Gaming
  • Hardware
  • IA
  • Mobile
  • What's new
  • Networks
  • Security
  • Software
  • Tutorials
  • Windows

Copyright © 2025 https://mastertrend.info/ - All rights reserved. All trademarks are property of their respective owners.

wpDiscuz
RedditBlueskyXMastodonHacker News
Share this:
MastodonVKWhatsAppTelegramSMSLineMessengerFlipboardHacker NewsMixNextdoorPerplexityXingYummly
Your Mastodon Instance