In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the relevant knowledge of "how to get started with Git quickly at work". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
(1) what is Git used for
If you enter an Internet company, you must hear about version control, which is to record the modification history of files, code, etc., to facilitate viewing, backing up, and rolling back historical code during development.
At the same time, it can be used to manage multi-person collaborative development projects, achieve multi-individual parallel development through version control, and improve development efficiency.
Git is an implementation of version control, as well as Svn.
Git can also be called distributed version control, all version information repositories are synchronized to the local of every other user, can be submitted offline locally, and push to the corresponding server when there is a network.
(2) the use of Git
Git is generally used on the command line. If it is a windows computer, you can see git bash and git gui with the right mouse button after installation. It is recommended to use git bash. After the installation of the mac computer, you can directly use the git command in the terminal.
Configuration information # View all configuration information git config-- list# view system configuration git config-- system-- list# view global configuration git config-- global-- list2.2 setting username and mailbox git config-- global user.name "javayz" git config-- global user.email "xxx@qq.com"
The first two steps belong to the configuration section after git installation. Next, we will introduce the use of git.
2.3 initialize the local git repository
If you want to turn a local folder into a git repository, just execute
Git init2.4 clone remote warehouse
If you want to download the code from the remote warehouse locally, you only need to execute it in a directory
Git clone [url] git clone-b [branchname] [url]
Where-b represents the code to clone the specified branch
2.5 submit files three steps # add files to the staging area git add filename# submit the files in the staging area to the local git commit-m "submission information" git push
We can also use to pull and submit the code directly, which is more convenient.
(3) the working principle of Git
There are four important areas in git:
Working directory (Working Directory): the place where the project code is usually stored
Temporary storage area (Stage): temporary storage changes
Resource library (Repsitory/Git Directory): all versions of data submitted
Remote Warehouse (Remote Directory): a platform for code hosting
Working directory-- > git add files-- > temporary storage area-- > git commit-- > resource repository-- > git push-- > remote warehouse
(4) Git ignores file upload
Creating a .gitignore file in the home directory can ignore submitting some files
* .txt # ignores all files ending with .txt! except a.txt # a.txt temp/ # ignores files in the temp directory (v) ssh login ssh-keygen-t rsa-C "xxx@qq.com"
After three consecutive returns, an id_rsa and id_rsa.pub are generated under the .ssh directory. Save the string in id_rsa.pub to the ssh public key in the gitee setting to avoid secret submission of the download code.
(6) Branch management
Branch is the core of distributed version control, each branch is not related to each other, basically each version iteration will create a new branch.
# list all branches git branch# list all remote branches git branch- r # create a new branch, but still stay in the current branch git branch [branch-name] # create a new branch And switch to the branch git checkout-b [branch] # merge the designated branch to the current branch git merge [branch] # Delete the branch git branch- d [branch-name] # Delete the remote branch git push origin-- delete [branch-name] git branch- dr [remote/branch] (VII) Integration of Git and Idea
Idea itself supports the integration of Git. When we clone a project locally and open it with Idea, we will find that there is a logo of git in the upper right corner:
The first blue arrow indicates that the code of the remote warehouse is pull locally.
The second green check box indicates the submission code. Check the code for commit and push, fill in the submission information, and then commit and push.
The third alarm clock shape is the submission history, you can view the history submission information.
This is the end of the tutorial on how to get started with Git at work. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.