git branch of Jenkins continuous integration
Posted by tzikis on Mon, 02 Dec 2019 22:43:47 +0100
What is a branch
The method of starting a separate development line in software project
Why git
1. It can avoid the problem of version compatibility development and the interaction between different versions.
2. Encapsulate a development phase.
3. When solving a bug, create a new branch to study the bug.
Branch related commands in git
git branch branch name - create a new branch
git branch - list all branches without any parameters. The * sign in front of the branch indicates that the branch is the current branch
*When creating a branch, the branch name cannot use special symbols
git branch -d branch name - delete branch
git branch -m old branch name new branch name - branch name changed
git checkout Branch Name: switch the branch. If the file is modified on the branch and there is no commit, switch to another branch
An error will be reported at this time, because files without commit will not be overwritten after branch switching
git checkout -f branch name --- force branch switching.
git branch display
kangdeMacBook-Air:cedarhd kang$ git branch #View all branches
* master
kangdeMacBook-Air:cedarhd kang$ git branch v1.0 #Create a new v1.0 branch
kangdeMacBook-Air:cedarhd kang$ git branch
* master
v1.0
kangdeMacBook-Air:cedarhd kang$ git checkout v1.0 #Branch to v1.0
Switched to branch 'v1.0'
kangdeMacBook-Air:cedarhd kang$ git branch
master
* v1.0
kangdeMacBook-Air:cedarhd kang$ touch test9.txt #Create test9.txt on the v1.0 branch
kangdeMacBook-Air:cedarhd kang$ ls -al
total 32
drwxr-xr-x 13 kang staff 442 12 2 00:12 .
drwxr-xr-x 5 kang staff 170 12 1 16:48 ..
drwxr-xr-x 16 kang staff 544 12 2 00:12 .git
-rw-r--r-- 1 kang staff 3 12 1 16:18 test.txt
-rw-r--r-- 1 kang staff 23 12 1 16:18 test1.txt
-rw-r--r-- 1 kang staff 0 12 1 16:18 test2.txt
-rw-r--r-- 1 kang staff 6 12 1 16:18 test3.txt
-rw-r--r-- 1 kang staff 17 12 1 16:18 test4.txt
-rw-r--r-- 1 kang staff 0 12 1 16:21 test5.txt
-rw-r--r-- 1 kang staff 0 12 1 16:37 test6.txt
-rw-r--r-- 1 kang staff 0 12 1 22:43 test7.txt
-rw-r--r-- 1 kang staff 0 12 1 23:15 test8.txt
-rw-r--r-- 1 kang staff 0 12 2 00:12 test9.txt
kangdeMacBook-Air:cedarhd kang$ git add test9.txt #Commit to staging area
kangdeMacBook-Air:cedarhd kang$ git commit -m "test9.txt" #Submit to local warehouse
[v1.0 6111bf3] test9.txt
Committer: kang <kang@kangdeMacBook-Air.local>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:
git config --global --edit
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 test9.txt
kangdeMacBook-Air:cedarhd kang$ ls -al
total 32
drwxr-xr-x 13 kang staff 442 12 2 00:12 .
drwxr-xr-x 5 kang staff 170 12 1 16:48 ..
drwxr-xr-x 16 kang staff 544 12 2 00:12 .git
-rw-r--r-- 1 kang staff 3 12 1 16:18 test.txt
-rw-r--r-- 1 kang staff 23 12 1 16:18 test1.txt
-rw-r--r-- 1 kang staff 0 12 1 16:18 test2.txt
-rw-r--r-- 1 kang staff 6 12 1 16:18 test3.txt
-rw-r--r-- 1 kang staff 17 12 1 16:18 test4.txt
-rw-r--r-- 1 kang staff 0 12 1 16:21 test5.txt
-rw-r--r-- 1 kang staff 0 12 1 16:37 test6.txt
-rw-r--r-- 1 kang staff 0 12 1 22:43 test7.txt
-rw-r--r-- 1 kang staff 0 12 1 23:15 test8.txt
-rw-r--r-- 1 kang staff 0 12 2 00:12 test9.txt
kangdeMacBook-Air:cedarhd kang$ git branch
* master
v1.0
kangdeMacBook-Air:cedarhd kang$ git checkout master #Switch to master branch
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
kangdeMacBook-Air:cedarhd kang$ ls -al #At this time, test9.txt of v1.0 is missing
total 32
drwxr-xr-x 12 kang staff 408 12 2 00:12 .
drwxr-xr-x 5 kang staff 170 12 1 16:48 ..
drwxr-xr-x 16 kang staff 544 12 2 00:12 .git
-rw-r--r-- 1 kang staff 3 12 1 16:18 test.txt
-rw-r--r-- 1 kang staff 23 12 1 16:18 test1.txt
-rw-r--r-- 1 kang staff 0 12 1 16:18 test2.txt
-rw-r--r-- 1 kang staff 6 12 1 16:18 test3.txt
-rw-r--r-- 1 kang staff 17 12 1 16:18 test4.txt
-rw-r--r-- 1 kang staff 0 12 1 16:21 test5.txt
-rw-r--r-- 1 kang staff 0 12 1 16:37 test6.txt
-rw-r--r-- 1 kang staff 0 12 1 22:43 test7.txt
-rw-r--r-- 1 kang staff 0 12 1 23:15 test8.txt
kangdeMacBook-Air:cedarhd kang$ git checkout v1.0 #Switch to v1.0 branch
Switched to branch 'v1.0'
kangdeMacBook-Air:cedarhd kang$ ls #test9.txt exists
test.txt test2.txt test4.txt test6.txt test8.txt
test1.txt test3.txt test5.txt test7.txt test9.txt
Topics:
Linux
git