What is the meaning of Git
Version and installation
Check which version of git is installed (git is pre-installed on Linux and Mac devices).
You can go to the installation guide if you haven't already installed git.
Add username and email address
Your Git username and email address are used to identify you as the author: in when you add code to a repository.
Enter the following command to configure your username:
Display the username you have entered:
Now enter your email address.
Display the e-mail address you have entered:
You can also read out all entered information at the same time:
Work with projects
A visualization of the git workflow helps to understand the various commands such as clone, push, pull, merge and fetch.
Git is a decentralized version management. This means that the developer and server environment are not separate. Every developer has both one Workspace (these are the files you are currently working on) and a Repository, also called a clone, which contains all versions and branches of a project.
If GitLab is used, there is also a central repository with which the project is managed.
If you have created a project in the GitLab web application and want to work with it on your computer, you must first create a local copy.
Clone The project in the directory on your computer in which you are currently located. To do this, navigate in the web application to the project you want to work on. Select in the drop-down menu under the title SSH and then copy the line indicated to the right of it.
Then paste this into the following terminal command:
If you now use the list command (ls) to display the contents of the current local directory, you will find a copy of the GitLab project that you have just cloned. You can now add, edit or delete files from the project.
The status command displays all files for which a change has been registered since the last commit. Changed files are highlighted in red.
If you've made any changes, you should add them to the index Add. This is a listing of files that are for the next Commit are prepared. At git, a commit is a project version.
To add all changed files to the index at once:
If you now enter the status command again, all files that are intended for the next commit are highlighted in green.
You are now ready to commit, including a brief description of the change. Please note that this does not update the repository on GitLab, only your local repository.
If you now want to add your changes to the remote repository, i.e. the GitLab project, you can do this using the push command.
REMOTE is the name of the remote server. If you clone a project, the default name given by git is origin. You can also specify the branch in which the project should be added.
To add your changes to the master branch:
If you now navigate to the project folder via the GitLab web application and in the left side menu in the category Repository on Commits then the change appears in the commit overview. In addition, the project has been updated with the changes that you made locally.
Look at history
You can view past commits with the following command, with the most recent commit first:
git fetch, git merge, git pull
There are three git commands to fetch changes from the remote repository and synchronize them with your local files.
- fetch pulls changes from the remote repository, but doesn't apply them to your code.
- merge synchronizes changes fetched via fetch with the workspace.
- pull performs fetch and merge. This fetches changes from the remote repository and synchronizes them with the workspace.
The fetchCommand allows changes to be fetched from a remote repository into the local repository. Changes are saved in the local repository in a remote branch and can thus be viewed first. They can then be integrated with the merge command. Since the downloaded changes are saved in a branch in the local repository, they can be viewed with the checkout command.
First, fetch the changes from the remote repository:
Then display all branches:
The following example is master the local branch you are currently on. The project version of the remote repository in the branch remotes / origin / master saved.
To view the changes that have just been fetched, run the following command:
This insightful video explains the fetch command in more detail.
With the pullCommand, you can fetch changes from a remote repository and synchronize them with your workspace, i.e. the files you are currently working on. You can specify the path to a repository and the branch from which you want to fetch changes. In short: git pull = git fetch + git merge.
A branch is an independent development branch. You can view all branches, both in the local and in the remote repository, with the following command:
Enter the following command to create the new local branch (here: new_Feature) and switch to this branch:
With the checkout command you can switch between the different branches at any time (here: switch to the master branch):
You can add your code to the remote new_feature branch of your GitLab project with the following command:
If you now navigate to your project in the GitLab web application, the new branch will be displayed in the branch overview.
- What is petrology in geology
- Does Google have a political agenda
- Why do I keep peeing in my pants
- What is the antonym of evil
- Do you like to hear the truth?
- What books should entrepreneurs read about finance?
- How does the vacuum transmit light
- How many C languages are there
- Where can I buy furniture in bulk
- Could we teach animals to speak?
- How to say guilty in Italian
- What is your favorite sound
- How effective is mobile marketing
- When will the FIITJEE results come
- How do Japanese names work
- Can a unicycle overtake a bicycle
- Is love different in different countries?
- Have fused Steven and Amethyst 1
- What is condensation and freezing
- What makes the Nissan Skyline so special
- What are Swedish national events
- How are app installations measured in advertising
- Why are we stuck in nationalism
- Why do referees keep boxers after TKOs