A brief introduction to the use of git tools

Baidu Encyclopedia wrote
Git is a free, open source distributed version control system for handling any project, small or large, with agility and efficiency. Git is pronounced /gɪt/. Git is an open source distributed version control system for efficient and high-speed version management of projects ranging from very small to very large. Git is an open source version control software developed by Linus Torvalds to help manage Linux kernel development.

 
In today's era of rapid development of the computer industry, software development as a typical representative of its development momentum should not be underestimated. We all know that the process of software development is a process of teamwork. How can we achieve more efficient and orderly cooperation in this process? At this time, the remote code base is used to manage the project projects of your team in a more reasonable, real-time and orderly manner. Now I will introduce the use and functions of git.

1. First, we need to register a user on GitHub or Git@OSC to provide us with a remote code repository. (GitHub and Git@OSC both provide free remote code repository management services)
GitHub URL: https://github.com/
Git@OSC URL: http://git.oschina.net/

Second, you can then create a local repository under your project project folder.

$git init
//Create a local warehouse (note: execute in your project folder)

 3. Some operations and usage of Git.

 

1. Workflow


 

$git status
//View the current git working status

$git add octocat.txt
//Save your operations on octocat.txt to the staging area

$git add .
//Save all your current operations to the temporary storage area (Index)

$git commit -m 'Add cute octocat story'
//Submit the changes of the files in the staging area to the local git library (HEAD), and add the description information of the file changes after "-m"

 2. Branch operation

$git branch feature_x
//Create a branch named feature_x

$git checkout -b feature_x
//Create and switch to the feature_x branch

$git checkout master
//Switch to the main branch master

$git merge feature_x
//Merge feature_x to the main branch master

$git branch -d feature_x
// delete branch feature_x

 4. After the modification in the local library is completed, it can be pushed to the remote Git library.

 

$git push origin master
//Push the master branch to the remote Git repository whose source is origin

$git pull https://git.oschina.net/****/mycode.git
//Pull content from the remote Git repository whose source address is the above address

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326923933&siteId=291194637