• About Us
  • Announce
  • Privacy Policy
  • Contact us
MasterTrend Info - Technology, News and Tutorials
  • 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 Info - Technology, News and Tutorials
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
0
10 Basic Git Commands to Get You Started
29
SHARED
81
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:
17FacebookLinkedInPinterestXRedditTumblrBlueskyThreadsShareChatGPTClaudeGoogle AIGrok
17
SHARES
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

WiFi Calling on iPhone. Woman showing on an iPhone the WiFi Calling option enabled in settings, guide on how to enable and use WiFi Calling on iPhone step by step.
Tutorials

WiFi Calling on iPhone: how to enable and use it

April 26, 2026
150
Advanced on-screen TV settings with brightness, contrast, sharpness, color, motion flow and HDR tone mapping configuration on a 4K UHD TV displaying a cinematic scene in high definition.
Tutorials

Advanced TV settings: what to change and what to avoid

April 7, 2026
247
iPhone call forwarding activated from settings, showing the β€œCall Forwarding” option enabled on the mobile phone screen.
Tutorials

iPhone call forwarding: how to activate and use it

April 27, 2026
222
Actual charging speed on your Android phone shown in a charging meter app with amperage and battery status on screen, while a woman holds the smartphone in a technology store.
Tutorials

Actual Loading Speed ​​on Your Android Phone

February 22, 2026
175
Accidental Echo Activation - Woman annoyed by the accidental activation of Alexa on an Amazon Echo speaker in a domestic living room.
Tutorials

Accidental activation of Echo on Amazon speakers

February 9, 2026
186
PNG to PDF Methods - Illustration of methods to convert PNG files to PDF, showing PNG and PDF icons with a conversion arrow between both formats.
Tutorials

PNG to PDF conversion methods: A comparison to help you choose in Windows 11

April 27, 2026
302
next post
Fallos de verificaciΓ³n del kernel

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
  • Trends
  • Comments
  • Last
πŸ–₯️ How to open 'Devices and printers' in Windows 11: 4 simple steps

🌟 How to open β€˜Devices and printers’ in Windows 11: Β‘Amazing trick!

April 28, 2026
Windows 11 Persistent Clock

Windows 11 Persistent Clock: Options, Limits, and Real Decisions

April 28, 2026
Ethernet not working in Windows 11: 9 easy tricks

Ethernet not working in Windows 11: 3-minute solution ⚑🌐

13 November 2025
How to save game in REPO

How to save game in REPO πŸ”₯ Discover the secret to not losing progress

7 July 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
AMD UDNA architecture for PS6 and Xbox Next, detail of next-generation GPU chip with advanced design for high-performance gaming consoles.

UDNA architecture in PS6 and Xbox Next: more than just numbers

4 de May de 2026
FBC Firebreak Weapons: Unlock and Priorities - Tactical operators with shotguns and flamethrowers in combat surrounded by fire in intense video game scene.

FBC Firebreak Weapons: Unlocking and Priorities

May 3, 2026
Strategy Heroes Olden Era: White-haired warrior heroine making key decisions in an epic fantasy battle that change the course of the game.

Heroes Olden Era Strategy: Game-Changing Decisions

May 3, 2026
Shoring Up Defenses in Arc Raiders: real strategy with player in desert facing enemy drones in intense sci-fi tactical battle.

Shoring Up Defenses in Arc Raiders: Royal Strategy

May 3, 2026

Recent News

AMD UDNA architecture for PS6 and Xbox Next, detail of next-generation GPU chip with advanced design for high-performance gaming consoles.

UDNA architecture in PS6 and Xbox Next: more than just numbers

4 de May de 2026
112
FBC Firebreak Weapons: Unlock and Priorities - Tactical operators with shotguns and flamethrowers in combat surrounded by fire in intense video game scene.

FBC Firebreak Weapons: Unlocking and Priorities

May 3, 2026
101
Strategy Heroes Olden Era: White-haired warrior heroine making key decisions in an epic fantasy battle that change the course of the game.

Heroes Olden Era Strategy: Game-Changing Decisions

May 3, 2026
144
Shoring Up Defenses in Arc Raiders: real strategy with player in desert facing enemy drones in intense sci-fi tactical battle.

Shoring Up Defenses in Arc Raiders: Royal Strategy

May 3, 2026
105
MasterTrend Info 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

AMD UDNA architecture for PS6 and Xbox Next, detail of next-generation GPU chip with advanced design for high-performance gaming consoles.

UDNA architecture in PS6 and Xbox Next: more than just numbers

4 de May de 2026
FBC Firebreak Weapons: Unlock and Priorities - Tactical operators with shotguns and flamethrowers in combat surrounded by fire in intense video game scene.

FBC Firebreak Weapons: Unlocking and Priorities

May 3, 2026
  • 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