Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to analyze Gitlab and get started with Git

2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, the editor will bring you an analysis of how to conduct Gitlab and an introduction to Git. The article is rich in content and analyzed and described from a professional point of view. I hope you can get something after reading this article.

If you haven't heard of Git or used Git by now, it's recommended to learn it as soon as possible, because it's useful. Although it is to do the algorithm, but programming is still essential. A year ago, I really never used or heard of these three. Later I knew Github, and now I know Gitlab, and I use Git to manage the code of the project every day. (mainly the code of merge boss, cry). Let's start with the introduction.

OK, let me first say that Github,Github is a website that provides code hosting service, that is, you can put your code there without fear of losing it. There are two ways to play it, one is to make your code public (visible to everyone), which is free, and the other is that only you can see the code (only you can see it), but it's for a fee. Then say that Gitlab,Gitlab and Github are similar, the difference is that when hosting code that is only visible to you on Gitlab, there is no charge, which facilitates similar projects developed by companies themselves, which can only be seen by internal members and not externally. Finally, Git,Git is a tool for managing code, so why manage code? You may not feel how important this is when you are new to programming, but you will feel it when you start working on some projects. Take a chestnut, just like when we have some graduation thesis, there may be many versions, what change 1, change 2, change 3. And so on a variety of naming methods, but this seems to be very messy, is there a tool to help me to manage, so that I can correct the wrong can go back and so on. Git is the result of the application, and Git is the artifact of managing code in project development. Tell me what problems you will face in project development. First of all, it is common for at least one person or several members to work together to complete a project. When there are a large number of people, there will be a manager (technical boss) and several collaborators (younger brothers) below. Then everyone will write their own code locally, and the location where the code is stored is called the local warehouse, and the code placed on the Github or Gitlab is called the remote repository. Then everyone will write some code every day, store it in the local warehouse, and then submit it to the remote warehouse. After reading it, the boss will add it to the main branch of the project if there is no problem. Here to talk about the concept of branches, branches can represent each different developer, and then there is a difference between the main branch and other branches. The main branch is the code that eventually needs to be online, while the other branches are the code in development. Every time the main branch code is updated, the boys need to download the main branch code and continue to develop new tasks. To cycle through the process.

OK, said a lot of nonsense, let's start with some practical information, here is only for the Linux system to explain, there is a client under Windows, as long as a little bit, can basically solve the problem, I have not used, not familiar with.

1. Git installation

Sudo apt-get install git-all

two。 Common command

Configure Git:

Git config-global user.name "your name"

Gitconfig-global user.email "your email"

The user name and mailbox are on Github or Gitlab.

View the configuration: git config-l, explicitly indicating that your user name and mailbox are configured correctly.

Create a new Git version library: git init

Add files to the cache:

Git add README.md

Submit documents to the warehouse:

Git commit-m "explanatory text about the code"

Submit the code to the remote warehouse:

Git push-u origin master

Gitpush origin master / / push the local master branch to the origin remote branch.

View the submission history:

Git log / / display the history of all submissions

Git log-- graph / / output the graph of branch transformation

Version fallback:

Git reset-- hard head ^ / / fallback to the previous submitted version

Git reset-- hard head ^ / / fallback to the previous submitted version

Git reset-- hard "commit_id" / / fallback to the submitted version specified by commit_id

Undo the changes:

Git checkout-- README.md / / is followed by the name of the file to be undone

Gitcheckout. / / undo all modified files in the current directory

Discard changes that have been added to the cache:

Git reset HEAD README.md

Create a new branch:

Git checkout-b new_branch_name / / create a branch and switch to a new branch

Or git branch new_branch_name.

Toggle branches:

Git branch new_branch_name

Delete the branch:

Git branch-d new_branch_name

View Git status: git status

Clone from the remote warehouse to the local warehouse:

The git clone * / / * symbol indicates the link to the code to be cloned. There are two methods: http and ssh.

Update the local warehouse from the remote warehouse:

Git checkout master

Git pull

Git checkout 'name of its own branch'

Git merge mster

Add SSH key:

First create a ssh key:

Ssh-keygen-t rsa-C "email address"

/ / if you directly enter ssh-keygen, it seems to be OK. If you do not have ssh, you need to install it first

Then find the file with the .pub suffix in the specified directory according to the output information, and open the replication information. Then open Github to setting under your home page, and there is an option to add ssh key. Just paste the information you just copied into it. In this way, you don't have to enter a user name and password every time you clone code.

The above is the editor for you to share how to carry out Gitlab analysis and Git introduction, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report