The right Git commands allow you to use version control software in the most efficient way. Here are the most important commands, to be executed via the terminal.
Cheap internet domain
Much more than just a domain!
Personalize your online presence with a relevant domain name.
Git commands make work easier
the version management software Git is a premier tool for all developers. It optimizes workflows for small and large teams who wish to work in parallel on their projects, and additionally guarantees the necessary security and stability. It is precisely when developing with multiple people, multiple trees, and multiple repositories that Git plays a crucial role in providing an overview to everyone in the workgroup. Git commands are essential for working with the software. These allow all work steps to be carried out for optimal use. Here are the main Git commands.
Before getting started with Git
Before starting a new project, first check if Git is already installed and which version is on your computer. To find out, the appropriate command is:
Whether no version number does not appear, you need first install Git. In Linux, use the package manager for this. On Mac, the installation is done via the terminal. Finally, for Windows, you just need to download Git and then open the installer.
To now start a new project for Git, call the desired folder in the terminal and create a new repository with the following command:
If you want to copy an already created repository or a deleted repository and insert it into the folder, it works via git clone:
git clone /chemin/source/Repository/chemin/cible
git clone https://gitexemple.fr/user/Repository.git
If you have already created an SSH key, this command also works:
git clone utilisateur@server:/chemin.git
Git commands to configure name and email
To be able to work on a project, you need a username and a valid associated email address. To do this, use the following Git commands:
To configure your username:
git config --global user.name "Nom-utilisateur"
Check your username:
git config --global user.name
Register your email address:
git config --global user.email "adresse-email@exemple.fr"
To view your address:
git config --global user.email
This command allows you to display all your data in the preview:
git config --global --list
Preview and Changes
A few important Git commands make it easier to make changes to your repository as well as this one. To get an overview of the repository, use this command:
git close gitexemple@exemple.fr:Repository.get
With this command you will get an overview of the local status and the changes that have not yet been submitted:
Changes are shown in red.
To check the differences between the pending commit and the latest current version, use git diff:
Git Commands for repositories
To save changes to the local repository yourself, you need the following Git commands.
Add all new, modified, or deleted files with this command:
On the other hand, if you want to save only certain changes to your commit, enclose them in square brackets:
git add [ fichier_1 fichier_2 fichier_3 | file-pattern ]
Here’s how to finalize a git commit:
If you also want to send explanations about the current step, here is the command:
git commit -m "Saisissez ici votre message"
With git Log, view the current commits in your local repository:
Git commands for branches
To work on a branch, use the following Git commands.
Show all branches:
Information on the different branches:
To list all branches in a local repository:
Create a new branch:
git branch nom-nouvelle-branche
Switch to a specific branch with git checkout:
git checkout nom-autre-branche
Create a new branch and switch:
git checkout -b nouvelle-branche
Move the new branch from the local repository to the commit:
git push -i depot-distant nouvelle-branche
Delete branch from local repository if it only contains accepted changes:
git branch -d nom-branche
Add changes from one branch to the current branch:
git merge nom-autre-branche
To pull changes from a remote repository, use git pull:
Git commands for tags
If you use tags, these Git commands will make your job easier.
List all tags:
Call all commit tags for your local repository:
Display a specific tag:
To move a specific tag into the commit, use git push:
git push nom-distant exemple-tag
Move all tags into the commit:
git push nom-distants --tags
Delete a tag from the local repository:
Work better with Git
These Git commands help to work quickly and efficiently in version control software. In our Digital Guide, you will also find a Git tutorial for a good start, as well as a summary of Git commands or Git Cheat Sheet with a very practical PDF to download. If you are looking for an alternative to Linus Torvalds’ software, our Git and SVN comparison will allow you to see more clearly.
Advice
With Deploy Now, create your online project in just three steps. This speeds up and facilitates the putting online of static sites and single-page Web applications for your customers.