【Git版本控制 05】多人协作

目录

一、邀请开发用户

二、新建远程分支

三、拉取远程分支

四、推送远程分支

五、合并远程分支

六、多分支协作


一、邀请开发用户

在windows环境下,再clone同⼀个项⽬仓库,来模拟⼀起协作开发的另⼀名⼩伙伴。

际开发中,每个⽤⼾都有⾃⼰的 gitee/github 账号,如果要多⼈进⾏协同开发,必须要将⽤⼾添加进开发者,⽤⼾才有权限进⾏代码提交:

至此相当于有了两个⽤⼾,分别在linux和windows上针对于同项⽬进⾏协作开发。

二、新建远程分支

⽬前,我们的仓库中只有⼀个maste主分⽀,但在实际的项⽬开发中,在任何情况下其实都是不允许直接在master分⽀上修改代码的,这是为了保证主分⽀的稳定。所以在开发新功能时,常常会新建其他分⽀,供开发时进⾏迭代使⽤。

创建成功的远程分⽀是可以通过Git拉取到本地来,以实现完成本地开发⼯作。

三、拉取远程分支

接下来让我们和另⼀名开发的⼩伙伴都将远程仓库进⾏⼀次拉取操作,并观察结果:

# Linux系统
# git branch 是查看本地分支
# git branch -r 可查看远端分支(base) [root@localhost git-learning]# git pull
来自 gitee.com:hdu-a-chao/git-learning* [新分支]          dev        -> origin/dev
Already up-to-date.
(base) [root@localhost git-learning]# git branch -rorigin/HEAD -> origin/masterorigin/devorigin/master
(base) [root@localhost git-learning]#
# Window系统C:\Users\pheonixFly\Gitee\git-learning>git pull
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
From https://gitee.com/hdu-a-chao/git-learning* [new branch]      dev        -> origin/dev
Already up to date.C:\Users\pheonixFly\Gitee\git-learning>git branch -rorigin/HEAD -> origin/masterorigin/devorigin/masterC:\Users\pheonixFly\Gitee\git-learning>

拉取后便可以看到远程的dev分⽀,接着切换到dev分⽀供我们进⾏本地开发。

需要注意的是,我们切换到的是本地dev分支,在切换的时候将本地分支和远程分支相连接。

# Linux系统
# git branch -a 是列出所有本地分支和远程分支(base) [root@localhost git-learning]# git checkout -b dev origin/dev
分支 dev 设置为跟踪来自 origin 的远程分支 dev。
切换到一个新分支 'dev'
(base) [root@localhost git-learning]# git branch -a
* devmasterremotes/origin/HEAD -> origin/masterremotes/origin/devremotes/origin/master
(base) [root@localhost git-learning]#
# Windows系统C:\Users\pheonixFly\Gitee\git-learning>git checkout dev
Switched to a new branch 'dev'
Branch 'dev' set up to track remote branch 'dev' from 'origin'.C:\Users\pheonixFly\Gitee\git-learning>

四、推送远程分支

# Linux系统(base) [root@localhost git-learning]# vim file.txt 
(base) [root@localhost git-learning]# cat file.txt
complete the first function!
(base) [root@localhost git-learning]# git add .
(base) [root@localhost git-learning]# git commit -m "first function"
[dev 25fed23] first function1 file changed, 1 insertion(+)create mode 100644 file.txt
(base) [root@localhost git-learning]# git push origin dev
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 282 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Powered by GITEE.COM [1.1.5]
remote: Set trace flag 0d4dcf8c
To git@gitee.com:hdu-a-chao/git-learning.git8d78346..25fed23  dev -> dev
(base) [root@localhost git-learning]# 

⾄此,我们已经将代码成功推送⾄码云,接下来假如你的⼩伙伴要和你协同开发,碰巧也要对file.txt⽂件作修改,并试图推送。

# Windows系统,推送失败C:\Users\pheonixFly\Gitee\git-learning>type file.txt
complete the second functionC:\Users\pheonixFly\Gitee\git-learning>git add .C:\Users\pheonixFly\Gitee\git-learning>git commit -m "second function"
[dev d1b29e4] second function1 file changed, 1 insertion(+)create mode 100644 file.txtC:\Users\pheonixFly\Gitee\git-learning>git push origin dev
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
To https://gitee.com/hdu-a-chao/git-learning.git! [rejected]        dev -> dev (fetch first)
error: failed to push some refs to 'https://gitee.com/hdu-a-chao/git-learning.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.C:\Users\pheonixFly\Gitee\git-learning>

推送失败,因为你的⼩伙伴的最新提交和你推送的提交有冲突,解决办法也很简单,Git已经提⽰我们,先⽤ git pull 把最新的提交从 origin/dev 抓下来,然后,在本地进⾏合并,并解决冲突,再推送。

# Windows系统C:\Users\pheonixFly\Gitee\git-learning>git pull
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 262 bytes | 37.00 KiB/s, done.
From https://gitee.com/hdu-a-chao/git-learning8d78346..25fed23  dev        -> origin/dev
CONFLICT (add/add): Merge conflict in file.txt
Auto-merging file.txt
Automatic merge failed; fix conflicts and then commit the result.C:\Users\pheonixFly\Gitee\git-learning>type file.txt
<<<<<<< HEAD
complete the second function
=======
complete the first function!
>>>>>>> 25fed23cedd3bf5d229bc6ec6d7b3bdc22863b7bC:\Users\pheonixFly\Gitee\git-learning>
# Windows系统,修改冲突文件,重新提交C:\Users\pheonixFly\Gitee\git-learning>type file.txt
complete the first function!
complete the second function!
C:\Users\pheonixFly\Gitee\git-learning>git add file.txtC:\Users\pheonixFly\Gitee\git-learning>git commit -m "merge dev"
[dev b81ee56] merge devC:\Users\pheonixFly\Gitee\git-learning>git push origin dev
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
Enumerating objects: 12, done.
Counting objects: 100% (12/12), done.
Delta compression using up to 16 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (9/9), 839 bytes | 839.00 KiB/s, done.
Total 9 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [1.1.5]
remote: Set trace flag 22432588
To https://gitee.com/hdu-a-chao/git-learning.git25fed23..b81ee56  dev -> devC:\Users\pheonixFly\Gitee\git-learning>

# Linux系统,查看最新的远程分支版本的代码(base) [root@localhost git-learning]# git pull
remote: Enumerating objects: 12, done.
remote: Counting objects: 100% (12/12), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 9 (delta 3), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (9/9), done.
来自 gitee.com:hdu-a-chao/git-learning25fed23..b81ee56  dev        -> origin/dev
更新 25fed23..b81ee56
Fast-forwardfile.txt | 1 +1 file changed, 1 insertion(+)
(base) [root@localhost git-learning]# cat file.txt
complete the first function!
complete the second function!(base) [root@localhost git-learning]# 

两名开发者已经开始可以进⾏协同开发了,不断的 git pull/add/commit/push ,遇到了冲突,就使⽤我们之前讲的冲突处理解决掉冲突。

虽然我们是在分⽀上进⾏多⼈协作开发,但最终的⽬的是要将开发后的代码合并到master上去,让我们的项⽬运⾏最新的代码。

五、合并远程分支

# Linux系统
# 1. 切换到 master 分支,pull 一下,保证本地 master 分支是最新内容
# 2. 切换到 dev 分支上合并 master 分支,避免合并冲突发生在 master 分支上
# 3. 切换到 master分支合并 dev分支
# 4. 将 master 分支推送到远程 origin/master 分支(base) [root@localhost git-learning]# git checkout master
切换到分支 'master'
(base) [root@localhost git-learning]# git pull
Already up-to-date.
(base) [root@localhost git-learning]# git checkout dev
切换到分支 'dev'
(base) [root@localhost git-learning]# git merge master
Already up-to-date.
(base) [root@localhost git-learning]# git checkout master
切换到分支 'master'
(base) [root@localhost git-learning]# git merge dev
更新 8d78346..b81ee56
Fast-forwardfile.txt | 2 ++1 file changed, 2 insertions(+)create mode 100644 file.txt
(base) [root@localhost git-learning]# cat file.txt
complete the first function!
complete the second function!(base) [root@localhost git-learning]# git status
# 位于分支 master
# 您的分支领先 'origin/master' 共 4 个提交。
#   (使用 "git push" 来发布您的本地提交)
#
无文件要提交,干净的工作区
(base) [root@localhost git-learning]# git push origin master
Total 0 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [1.1.5]
remote: Set trace flag f44bd18c
To git@gitee.com:hdu-a-chao/git-learning.git8d78346..b81ee56  master -> master
(base) [root@localhost git-learning]# git status
# 位于分支 master
无文件要提交,干净的工作区
(base) [root@localhost git-learning]# 

总结⼀下,在同⼀分⽀下进⾏多⼈协作的⼯作模式通常是这样:

  • ⾸先,可以试图⽤ git push origin branch-name 推送⾃⼰的修改;
  • 如果推送失败,则因为远程分⽀⽐你的本地更新,需要先⽤gitpull试图合并;
  • 如果合并有冲突,则解决冲突,并在本地提交;
  • 没有冲突或者解决掉冲突后,再⽤ git push origin branch-name推送就能成功!
  • 功能开发完毕,将分⽀ merge 进 master,最后删除分⽀。
     

六、多分支协作

⼀般情况下,如果有多需求需要多⼈同时进⾏开发,是不会在⼀个分⽀上进⾏多⼈开发,⽽是⼀个需求或⼀个功能点就要创建⼀个 feature 分⽀。

现在同时有两个需求需要你和你的⼩伙伴进⾏开发,那么你们俩便可以各⾃创建⼀个分⽀来完成⾃⼰的⼯作。

# Linux系统
# 在本地 feature1 分支上编写 function1 并推送到远程 feature1 分支(base) [root@localhost git-learning]# git branch -adev
* feature-1masterremotes/origin/HEAD -> origin/masterremotes/origin/feature-1remotes/origin/feature-2remotes/origin/master
(base) [root@localhost git-learning]# vim function1 
(base) [root@localhost git-learning]# cat function1 
Done!
(base) [root@localhost git-learning]# git add function1 
(base) [root@localhost git-learning]# git commit -m "add function1"
# 位于分支 feature-1
无文件要提交,干净的工作区
(base) [root@localhost git-learning]# git push origin feature-1
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 265 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Powered by GITEE.COM [1.1.5]
remote: Set trace flag b946fab3
To git@gitee.com:hdu-a-chao/git-learning.gitb81ee56..747de46  feature-1 -> feature-1
(base) [root@localhost git-learning]# 
# Windows系统
# 在本地 feature2 分支上编写 function2 并推送到远程 feature2 分支C:\Users\pheonixFly\Gitee\git-learning>git checkout -b feature-2
Switched to a new branch 'feature-2'C:\Users\pheonixFly\Gitee\git-learning>type function2
Done!C:\Users\pheonixFly\Gitee\git-learning>git add function2C:\Users\pheonixFly\Gitee\git-learning>git commit -m "add function2"
On branch feature-2
nothing to commit, working tree cleanC:\Users\pheonixFly\Gitee\git-learning>git push origin feature-2
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 16 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 271 bytes | 271.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [1.1.5]
remote: Set trace flag 554bf2b4
To https://gitee.com/hdu-a-chao/git-learning.gitb81ee56..5388bb8  feature-2 -> feature-2C:\Users\pheonixFly\Gitee\git-learning>

此时,在本地,你看不⻅他新建的⽂档,他看不⻅你新建的⽂档。并且推送各⾃的分⽀时,并没有任何冲突,你俩互不影响。

正常情况下,你俩就可以在⾃⼰的分⽀上进⾏专业的开发了,直到各自的功能实现完毕就合并到远程master分支上。

但天有不测⻛云,你的⼩伙伴突然⽣病了,但需求还没开发完,需要你帮他继续开发,于是他便把 feature-2 分⽀名告诉你了。这时你就需要在⾃⼰的机器上切换到 feature-2 分⽀帮忙继续开发。

# Linux系统,帮助小伙伴开发 function2
# 1. 拉取远端仓库
# 2. 新建本地 feature-2 分支并关联 origin/feature-2
#    若不连接,使用 git push 简写格式会推送失败
# 3. 帮助小伙伴开发 function2 并推送(base) [root@localhost git-learning]# git pull
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
来自 gitee.com:hdu-a-chao/git-learningb81ee56..5388bb8  feature-2  -> origin/feature-2
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for detailsgit pull <remote> <branch>If you wish to set tracking information for this branch you can do so with:git branch --set-upstream-to=origin/<branch> feature-1(base) [root@localhost git-learning]# git branch -adev
* feature-1masterremotes/origin/HEAD -> origin/masterremotes/origin/feature-1remotes/origin/feature-2remotes/origin/master
(base) [root@localhost git-learning]# git checkout -b feature-2 origin/feature-2
分支 feature-2 设置为跟踪来自 origin 的远程分支 feature-2。
切换到一个新分支 'feature-2'
(base) [root@localhost git-learning]# ls
file1  file1.ini  file1.so  file.ini  file.so  file.txt  function2  README.en.md  README.md
(base) [root@localhost git-learning]# vim function2 
(base) [root@localhost git-learning]# cat function2 
Done!
Help Done!
(base) [root@localhost git-learning]# git add function2 
(base) [root@localhost git-learning]# git commit -m "help done function2"
[feature-2 ead5633] help done function21 file changed, 1 insertion(+)
(base) [root@localhost git-learning]# git push
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 262 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Powered by GITEE.COM [1.1.5]
remote: Set trace flag d943ed88
To git@gitee.com:hdu-a-chao/git-learning.git5388bb8..ead5633  feature-2 -> feature-2
(base) [root@localhost git-learning]# 

这时,你的⼩伙伴已经修养的差不多,可以继续进⾏⾃⼰的开发⼯作,那么他⾸先要获取到你帮他开发的内容,然后接着你的代码继续开发,或者你已经帮他开发完了,那他也需要在⾃⼰的电脑上看看你帮他写的代码。

# Windows系统
# 发现并没有 pull 到最新的代码C:\Users\pheonixFly\Gitee\git-learning>git pull
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 242 bytes | 26.00 KiB/s, done.
From https://gitee.com/hdu-a-chao/git-learning5388bb8..ead5633  feature-2  -> origin/feature-2
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.git pull <remote> <branch>If you wish to set tracking information for this branch you can do so with:git branch --set-upstream-to=origin/<branch> feature-2C:\Users\pheonixFly\Gitee\git-learning>type function2
Done!C:\Users\pheonixFly\Gitee\git-learning>git status
On branch feature-2
nothing to commit, working tree cleanC:\Users\pheonixFly\Gitee\git-learning>

Pull⽆效的原因是⼩伙伴没有指定本地 feature-2 分⽀与远程 origin/feature-2 分⽀的链接,根据提⽰,设置feature-2和origin/feature-2的链接再重新拉取即可。

# Windows系统C:\Users\pheonixFly\Gitee\git-learning>git branch --set-upstream-to=origin/feature-2 feature-2
Branch 'feature-2' set up to track remote branch 'feature-2' from 'origin'.C:\Users\pheonixFly\Gitee\git-learning>git pull
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
Updating 5388bb8..ead5633
Fast-forwardfunction2 | 1 +1 file changed, 1 insertion(+)C:\Users\pheonixFly\Gitee\git-learning>type function2
Done!
Help Done!C:\Users\pheonixFly\Gitee\git-learning>

⽬前,⼩伙伴的本地代码和远端保持严格⼀致。你和你的⼩伙伴可以继续在不同的分⽀下进⾏协同开发了。

各⾃功能开发完毕后,我们需要将代码合并到 master 中才算真正意义上的开发完毕。

# Windows系统
# 小伙伴率先开发完毕,开始 mergeC:\Users\pheonixFly\Gitee\git-learning>git checkout master
Switched to branch 'master'
Your branch is behind 'origin/master' by 4 commits, and can be fast-forwarded.(use "git pull" to update your local branch)C:\Users\pheonixFly\Gitee\git-learning>git pull
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
Updating 8d78346..b81ee56
Fast-forwardfile.txt | 2 ++1 file changed, 2 insertions(+)create mode 100644 file.txtC:\Users\pheonixFly\Gitee\git-learning>git push origin master
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [1.1.5]
remote: Set trace flag 0645149a
To https://gitee.com/hdu-a-chao/git-learning.gitb81ee56..ead5633  master -> masterC:\Users\pheonixFly\Gitee\git-learning>
Switched to branch 'master'
Your branch is up to date with 'origin/master'.C:\Users\pheonixFly\Gitee\git-learning>git merge feature-2
Updating b81ee56..ead5633
Fast-forwardfunction2 | 2 ++1 file changed, 2 insertions(+)create mode 100644 function2C:\Users\pheonixFly\Gitee\git-learning>git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.(use "git push" to publish your local commits)nothing to commit, working tree cleanC:\Users\pheonixFly\Gitee\git-learning>git push origin feature-2
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
info: detecting host provider for 'https://gitee.com/'...
Everything up-to-dateC:\Users\pheonixFly\Gitee\git-learning>

当你的⼩伙伴将其代码 merge 到 master 后,这是你也开发完成了,也需要进⾏ merge 到 master 操作。

# Linux系统(base) [root@localhost git-learning]# git checkout master
切换到分支 'master'
(base) [root@localhost git-learning]# git pull
来自 gitee.com:hdu-a-chao/git-learningb81ee56..ead5633  master     -> origin/master
更新 b81ee56..ead5633
Fast-forwardfunction2 | 2 ++1 file changed, 2 insertions(+)create mode 100644 function2
(base) [root@localhost git-learning]# git checkout feature-1
切换到分支 'feature-1'
(base) [root@localhost git-learning]# git merge master
Merge made by the 'recursive' strategy.function2 | 2 ++1 file changed, 2 insertions(+)create mode 100644 function2
(base) [root@localhost git-learning]# ls
file1  file1.ini  file1.so  file.ini  file.so  file.txt  function1  function2  README.en.md  README.md
(base) [root@localhost git-learning]# git status
# 位于分支 feature-1
无文件要提交,干净的工作区
(base) [root@localhost git-learning]# git checkout master
切换到分支 'master'
(base) [root@localhost git-learning]# git merge feature-1
更新 ead5633..7111247
Fast-forwardfunction1 | 1 +1 file changed, 1 insertion(+)create mode 100644 function1
(base) [root@localhost git-learning]# ls
file1  file1.ini  file1.so  file.ini  file.so  file.txt  function1  function2  README.en.md  README.md
(base) [root@localhost git-learning]# git status
# 位于分支 master
# 您的分支领先 'origin/master' 共 2 个提交。
#   (使用 "git push" 来发布您的本地提交)
#
无文件要提交,干净的工作区
(base) [root@localhost git-learning]# git push origin master
Counting objects: 4, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 307 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Powered by GITEE.COM [1.1.5]
remote: Set trace flag 7b48b099
To git@gitee.com:hdu-a-chao/git-learning.gitead5633..7111247  master -> master
(base) [root@localhost git-learning]# 

此时, feature-1 和 feature-2 分⽀对于我们来说就没⽤了,那么我们可以直接在远程仓库中将dev分⽀删除掉。

远程分支删除后,但是我么本地 pull 后还是可以看到那些远程仓库已经不存在的分⽀。

使⽤ git remote prune origin 删掉那些远程仓库不存在的分⽀。

# 当我们在Gitee服务器上删除了 feature-1 feature-2(base) [root@localhost git-learning]# git pull
Already up-to-date.
(base) [root@localhost git-learning]# git branch -adevfeature-1feature-2
* masterremotes/origin/HEAD -> origin/masterremotes/origin/feature-1remotes/origin/feature-2remotes/origin/master
(base) [root@localhost git-learning]# git remote prune origin
修剪 origin
URL:git@gitee.com:hdu-a-chao/git-learning.git* [已删除] origin/feature-1* [已删除] origin/feature-2
(base) [root@localhost git-learning]# git branch -adevfeature-1feature-2
* masterremotes/origin/HEAD -> origin/masterremotes/origin/master
(base) [root@localhost git-learning]# 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/673776.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

vue的8大生命周期

第072个 查看专栏目录: VUE ------ element UI 专栏目标 在vue和element UI联合技术栈的操控下&#xff0c;本专栏提供行之有效的源代码示例和信息点介绍&#xff0c;做到灵活运用。 提供vue2的一些基本操作&#xff1a;安装、引用&#xff0c;模板使用&#xff0c;computed&a…

【Python】虚拟环境miniconda安装(python3.7, python3.x)

背景 使用Python开发项目时&#xff0c;我们一般都需要安装环境&#xff0c;可能是在物理机上直接安装&#xff0c;也可能是在虚拟环境上安装&#xff0c;当前是怎么按照conda环境的示例&#xff0c;可以指定安装Python3.x的所有版本。 安装 首先&#xff0c;需要登录当前的…

微信小程序(三十九)表单信息收集

注释很详细&#xff0c;直接上代码 上一篇 新增内容&#xff1a; 1.表单收集的基本方法 2.picker的不足及解决方法 源码&#xff1a; index.wxml <!-- 用户信息 --> <view class"register"><!-- 绑定表单信息收集事件--><form bindsubmit"…

计算两个数相除后的余数返回值为浮点型math.fmod(x, y)

【小白从小学Python、C、Java】 【计算机等考500强证书考研】 【Python-数据分析】 计算两个数相除后的余数 返回值为浮点型 math.fmod(x, y) [太阳]选择题 请问以下代码执行math.fmod()后输出的结果是&#xff1f; import math print("【执行】math.fmod(10, 4)"…

高斯伪谱C++封装库开源!

Windows x64/86 C无依赖运行高斯伪谱法求解最优控制问题&#xff0c;你只需要ElegantGP! Author: Y. F. Zhang His Github: https://github.com/ZYunfeii 写在前面 这个库在你下载它的那一时刻起不再依赖任何其他代码&#xff0c;直接可用来构建C的最优控制问题并进行求解。…

springboot163美食推荐商城的设计与实现

简介 【毕设源码推荐 javaweb 项目】基于springbootvue 的 适用于计算机类毕业设计&#xff0c;课程设计参考与学习用途。仅供学习参考&#xff0c; 不得用于商业或者非法用途&#xff0c;否则&#xff0c;一切后果请用户自负。 看运行截图看 第五章 第四章 获取资料方式 **项…

C++多线程:this_thread 命名空间

std::this_thread 是 C 标准库中提供的一个命名空间&#xff0c;它包含了与当前线程相关的功能。这个命名空间提供了许多与线程操作相关的工具&#xff0c;使得在多线程环境中更容易进行编程。 源码类似于如下&#xff1a; namespace std{namespace this_thread{//...........…

图片加速接口:缓存图片,加速访问,解决防盗链

CSDN会自动把图片存到自己的图床&#xff0c;测试效果不好&#xff0c;建议到 https://www.skyqian.com/archives/speed-up-picture.html 查看效果。 引言 不知道是否有遇到以下场景&#xff1a; 图片打开很慢&#xff01;因为图片源来自于国外。图片可以正常打开&#xff0c…

在C++的union中使用std::string(非POD对象)的陷阱

struct和union的对比 union最开始是C语言中的关键字&#xff0c;在嵌入式中比较常见&#xff0c;由于嵌入式内存比较稀缺&#xff0c;所以常用union用来节约空间&#xff0c;在其他需要节省内存的地方也可以用到这个关键字&#xff0c;写一个简单程序来说明union的用途 struc…

docker 运行jar包 指定配置文件

要在Docker中运行JAR包并指定配置文件&#xff0c;你可以创建一个Dockerfile来定义你的容器环境&#xff0c;并在其中指定如何运行JAR包和配置文件。下面是一个简单的例子&#xff0c;展示了如何在Dockerfile中设置这些配置&#xff1a; 第一步&#xff1a;创建 Dockerfile文件…

第十个知识点:继承

在ES6之后&#xff0c;javascript引入了类的概念&#xff0c;也就是说与java相同&#xff0c;我们可以在js文件中创建类与对象&#xff0c;然后通过extend继承 <script>class Father {constructor(name) {//父类构造器this.name name;}speak(){//父类方法console.log(我…

Codeforces Round 923 (Div. 3)E. Klever Permutation 找规律,有共同区间

Problem - E - Codeforces 目录 Source of idea: 思路&#xff1a; 代码&#xff1a; 另一个up的找规律的解法&#xff1a; Source of idea: Codeforces Round 923(A-F题解) - 哔哩哔哩 (bilibili.com) 思路&#xff1a; 上面up分析的很好。两个相邻区间也就端点不一样&…

使用Pillow来生成简单的红包封面

Pillow库&#xff08;Python Imaging Library的后继&#xff09;是一个强大而灵活的图像处理库&#xff0c;适用于Python。Pillow 库&#xff08;有时也称 PIL 库&#xff09; 是 Python 图像处理的基础库&#xff0c;它是一个免费开源的第三方库&#xff0c;由一群 Python 社区…

IAR报错:Error[Pa045]: function “halUartInit“ has no prototype

在IAR工程.c文件末尾添加一个自己的函数&#xff0c;出现了报错Error[Pa045]: function "halUartInit" has no prototype 意思是没有在开头添加函数声明&#xff0c;即void halUartInit(void); 这个问题我们在keil中不会遇到&#xff0c;这是因为IAR编译器规则的一…

FPGA_vga显示

一 VGA 1.1 VGA VGA是视频图像阵列&#xff0c;是一种使用模拟信号进行视频传输的标准协议。 1.2 VGA接引脚定义 VGA分公母两种&#xff0c;RGB显示标准。 1.3 VGA显示器 VGA显示器采用图像扫描的方式进行图像显示&#xff0c;将构成图像的像素点&#xff0c;在行同步信号…

7机器人位姿的数学描述与坐标变

由上次刚体的空间转动直接切换为机器人相关术语。 1.机器人位姿的数学描述与坐标变换 1.1位姿描述 {B}相对于{A}的姿态描述用3x3矩阵表示为&#xff1a; 式中为三个单位正交主矢量&#xff0c;分别表示刚体坐标系{B}的三个坐标轴XBYBZB在参考系{A}中的方位&#xff0c;∠XBXA表…

leetcode(滑动窗口)483.找到字符中所有字母异位词(C++详细解释)DAY4

文章目录 1.题目示例提示 2.解答思路3.实现代码结果 4.总结 1.题目 给定两个字符串 s 和 p&#xff0c;找到 s 中所有 p 的 异位词 的子串&#xff0c;返回这些子串的起始索引。不考虑答案输出的顺序。 异位词 指由相同字母重排列形成的字符串&#xff08;包括相同的字符串&a…

ChatGPT 3.5与4.0:深入解析技术进步与性能提升的关键数据

大家好&#xff0c;欢迎来到我的博客&#xff01;今天我们将详细比较两个引人注目的ChatGPT版本——3.5和4.0&#xff0c;通过一些关键数据来深入解析它们之间的差异以及4.0版本的技术进步。 1. 模型规模与参数 ChatGPT 3.5&#xff1a; 参数数量&#xff1a;约1.7亿个模型层数…

后端创建订单

package com.java1234.entity;import io.jsonwebtoken.Claims;/*** jwt验证信息* author java1234_小锋* site www.java1234.com* company Java知识分享网* create 2019-08-13 上午 10:00*/ public class CheckResult {private int errCode;private boolean success;private Cl…

前端JavaScript篇之数组的遍历方法有哪些?forEach和map方法有什么区别?

目录 数组的遍历方法有哪些&#xff1f;forEach和map方法有什么区别&#xff1f;forEach()map()filter()for…ofevery() 和 some()find() 和 findIndex()reduce() 和 reduceRight()forEach和map方法有什么区别总结 数组的遍历方法有哪些&#xff1f;forEach和map方法有什么区别…