How to clone the project locally on gitlab? The following article will introduce to you two correct postures for cloning projects from gitlab and commonly used git visualization tools. I hope it will be helpful to you!
We have created a project in the previous lesson. In this lesson, I will clone the project locally and then practice common git commands
There are two ways to git clone
clone
, one is SSH
, the other is HTTPS
, The main difference between the two cloning methods is:
- HTTPS only needs to copy the link, and then enter the clone command in git Bash to clone the project locally, but you need to enter the account every time you fetch and push the code and password; when using SSH, by default you do not need to enter the account password for each communication, but you need to configure and add the SSH key before cloning. The prerequisite for adding the SSH key is that you must be the owner of this project.
You can choose to download this code repository directly. After downloading, it will be a compressed package and will not carry the .git
file.
Now let’s clone our project first
Use the following command to directlyclone
,
git clone git@gitlab.com:fe-test1/git-demo.git
The first time you clone You enter your username and password. If you don’t know what your password is, you can modify it in Edit profiles->password
. The picture below shows the success of clone
.
Now let’s submit a message to test whether ours can be pushed to the remote warehouse.
Open the project and go to README.md
Just modify some information in the file, and then execute
# 添加代码到暂存区域 .添加所有文件 git add . # 提交commit信息 "feat" commit规范,后面章节会介绍 git commit -m "feat: 第一次提交代码"
Use git status
to check if there is any uncommitted code, prompting us that it is time to push
Execute git push
Push the code to the remote
shows that the push is successful and the code is pushed to the main
branch . Then let's go to the panel to see if it's the content we just submitted:
You can see the information we just modified and the commit information we submitted.
OK, reaching this point means that you have taken the first step in the company. I have heard many times that some self-proclaimed master programmers are questioned because they cannot even handle this thing, because many new programmers really don’t know how to do this! ! !
git remote
If we create a project locally, how do we establish a connection with the remote repository? The answer is to use git remote
Similarly, first you have to create a remote warehouse local-test
, and then create a folder locally local- test
, then add a READMD.md
file and add some information casually.
Execute the following command in the root directory of the folder:
# 初始化仓库 git init # 添加暂存区 git add . # 提交 git commit -m "feat: 建立与远程仓库的连接" # 添加远程源信息 git remote add origin git@gitlab.com:fe-test1/local-test.git # push代码到origin/main分支 git push -u origin main
It is considered successful if the code can be successfully pushed to the remote warehouse.
Summary: Generally, if there is an existing code warehouse, we tend to use the first method more. If we are creating a new warehouse and new project, we will use the second method.
vscode
vscode comes with its own git management tool. When we modify something, we can clearly see which files and contents have been modified,
#There are many operation shortcuts on the left side, including temporary storage, submission, push and other operations.
After installing the gitlens
plug-in, you can view other people's submission records, especially when merging conflicts, it is more convenient and faster.
gitkraken
Highly recommend this tool, you can easily create a remote warehouse on this tool, or clone the remote warehouse. Manage local repositories and more. Students who cannot access the Internet may not push the code for a long time. With this tool, you don’t need to worry about network problems at all. You can pull and push large files very quickly.
However, it can only be used on mac?
Download address: www.gitkraken.com/
(Learning video sharing: Basic Programming Video )
The above is the detailed content of A brief analysis of how to clone a project locally on gitlab. For more information, please follow other related articles on the PHP Chinese website!

GitHub is a distributed version control system based on Git, providing the core features of version control, collaboration and code hosting. 1) Creating repositories, cloning, committing and pushing changes is the basic usage. 2) Advanced usage includes using GitHubActions for automation, deploying static websites in GitHubPages, and using security features to protect code. 3) Common errors such as merge conflicts, permission issues and network connection issues can be debugged by manually resolving conflicts, contacting the warehouse owner and setting up a proxy. 4) Methods to optimize workflows include using branching strategies, automated testing and CI/CD, code review, and keeping documentation and annotations clear.

Git and GitHub are different tools: Git is a distributed version control system, and GitHub is an online collaboration platform based on Git. Git manages code through workspaces, temporary storage areas and local warehouses, and uses common commands such as gitinit, gitclone, etc. GitHub provides functions such as code hosting, PullRequest, IssueTracking, etc. The basic process includes creating repositories, pushing code, and collaborating with PullRequest.

Git and GitHub are key tools for modern software development. Git provides version control capabilities to manage code through repositories, branches, commits and merges. GitHub provides code hosting and collaboration features such as Issues and PullRequests. Using Git and GitHub can significantly improve development efficiency and team collaboration capabilities.

Git is a distributed version control system developed by Linus Torvaz in 2005, and GitHub is a Git-based code hosting platform founded in 2008. Git supports branching and merges through snapshot management files, and GitHub provides pull requests, problem tracking and code review functions to facilitate team collaboration.

Git and GitHub are key tools in modern software development. Git is a distributed version control system, and GitHub is a Git-based code hosting platform. Git's core features include version control and branch management, while GitHub provides collaboration and project management tools. When using Git, developers can track file changes and work together; when using GitHub, teams can collaborate through PullRequests and Issues.

GitHubiscrucialforsoftwaredevelopmentduetoitscomprehensiveecosystemforcodemanagementandcollaboration.Itoffersversioncontrol,communitysupport,andtoolslikeGitHubActionsandPages.Startbymasteringbasicslikecreatingarepository,usingbranches,andautomatingwo

Git and GitHub are essential tools for modern developers. 1. Use Git for version control: create branches for parallel development, merge branches, and roll back errors. 2. Use GitHub for team collaboration: code review through PullRequest to resolve merge conflicts. 3. Practical tips and best practices: submit regularly, submit messages clearly, use .gitignore, and back up the code base regularly.

Git and GitHub are not the same thing: Git is a distributed version control system, and GitHub is an online platform based on Git. Git helps developers manage code versions and achieve collaboration through branching, merge and other functions; GitHub provides code hosting, review, problem management and social interaction functions, enhancing Git's collaboration capabilities.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

Dreamweaver CS6
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
