Mastering GIT commands is a skill acquired over time. More than 3 million users of GitHub can verify this. However, you can Optimize your uptime with version control systems to learn basic GIT commands to be used in daily life.

git commands

The execution of these actions is not complicated. Learn more about each below:

1. Git configuration to enter username and email

The first GIT command to use to configure your username and email in the software. If you want to change the placed information, simply run the GIT config command without the “–global” option.

git config --global "John Doe"git config --global [email protected]

2. Git init to start a project

This command creates a new repository or imports an existing but not yet versioned folder. To run it, go to the project directory and type:

git init

3. rm git to remove files

The command performs the action of removing files from the platform, monitoring and associating to the selection area of ​​the repository used in the project.

git rm -f {arquivo}

4. Git clone to clone an existing repository

You can clone source code from a repository created by other developers using the GIT clone command. The operation can be performed with the following option:

git clone

5. Git branch to create, list or delete branches

For example, branches (branches) of a project on Github are what enable simultaneous coding work for several developers. A new branch is created with each change in the code.

  • To create a new branch, run the command:

git branch

  • If you want to see branches, type:

git branch --list

  • And to delete a branch there is this command:

git branch -d

6. Git checkout to switch between branches

What is git checkout command lets you exit one branch and access another implement the planned change. Use the shortcut with the -b parameter to create and modify branches.

git checkout

git checkout -b {nome-da-ramificação}

7. Git status to know the status of files

This GIT command helps you learn more about the branch you are on. When running the dev will know if the branch is up to date with master and what has changed so far.

git status

8. Git diff to drill down on trace data

The git diff command provides more detailed information about the file than the Git status command. With this, you can accurately visualize added or deleted lines of code.

git diff

9. Git add to include in next commit

Use the Git add command to ensure that changes made to the file are tracked and included in the next commit.

– add a single file:

git add

– add all files:

git add -A

10. Git push to push commits

The command sends the commits from the local repository to the remote server.

git push

If the branch is newly created, you need to install the branch by running:

git push -u origin

11. Git pull to pull and apply changes

This command is a combination of the other two commands. With git pull you can fetch the latest changes from the remote server (git fetch) and apply them to the local repository (git merge).

git pull

12. Git returns to undo changes

The git revert command is a safe action to delete a change made to the repository (local or remote).

git revert 'número do hash'

The hash number can be checked with the git log?–?oneline command.

13. Git reset to undo permanent changes

In addition to git revert, there is also a Git reset delete command. However, if the latter is applied, it cannot be undone. Be careful when operating!

git reset --hard HEAD~1

14. Git commits to set checkpoint

Its function is to store and verify the current contents of the directory. To run it, type:

git commit -m "mensagem explicando a mudança no código"

15. Git merge

Completing the list of git commands is the action taken to merge all branches into the local repository after your build is working the way you want it to.

git merge

Did you like the content? Check out the news about the world of technology. Technology World and learn about the latest releases from GitHub. And moreover, if you want to learn the difference between GIT and Github, it is useful to take a look at the article we have published on the subject. Until that time!

Powered by Froala Editor

Source: Tec Mundo

Previous articleApple reveals how to use Security Keys in iOS 16.3
Next articleMailchimp hacked for second time in less than six months


Please enter your comment!
Please enter your name here