Git团队协作
创建远程库别名
git remote -v #查看当前所有进程地址别名 git remote add 别名 远程地址 #起别名
ws199@DESKTOP-2N1I9JA MINGW64 /d/GIT/Git-Space/git.demo (hot-fix) $ git remote -v ws199@DESKTOP-2N1I9JA MINGW64 /d/GIT/Git-Space/git.demo (hot-fix) $ git remote add git.demo https://github.com/weishuoHH/git-demo.git ws199@DESKTOP-2N1I9JA MINGW64 /d/GIT/Git-Space/git.demo (hot-fix) $ git remote -v git.demo https://github.com/weishuoHH/git-demo.git (fetch) git.demo https://github.com/weishuoHH/git-demo.git (push)
推送本地分支上的内容到远程仓库
git push 别名 分支 #推送本地分支上的内容到远程仓库
ws199@DESKTOP-2N1I9JA MINGW64 /d/GIT/Git-Space/git.demo (master) $ git push git.demo master Enumerating objects: 21, done. Counting objects: 100% (21/21), done. Delta compression using up to 16 threads Compressing objects: 100% (14/14), done. Writing objects: 100% (21/21), 1.55 KiB | 792.00 KiB/s, done. Total 21 (delta 4), reused 0 (delta 0), pack-reused 0 remote: Resolving deltas: 100% (4/4), done. To https://github.com/weishuoHH/git-demo.git * [new branch] master -> master
克隆远程库到本地库
git clone 远程地址 #将远程仓库的内容克隆到本地 #clone操作: 1.拉取代码 2.初始化本地库 3.创建别名
ws199@DESKTOP-2N1I9JA MINGW64 /d/GIT/Git-lhc $ git clone https://github.com/weishuoHH/git-demo.git Cloning into 'git-demo'... remote: Enumerating objects: 27, done. remote: Counting objects: 100% (27/27), done. remote: Compressing objects: 100% (14/14), done. remote: Total 27 (delta 6), reused 20 (delta 4), pack-reused 0 Receiving objects: 100% (27/27), done. Resolving deltas: 100% (6/6), done. ws199@DESKTOP-2N1I9JA MINGW64 /d/GIT/Git-lhc $ ll total 0 drwxr-xr-x 1 ws199 197609 0 Apr 17 14:27 git-demo/ #创建别名 ws199@DESKTOP-2N1I9JA MINGW64 /d/GIT/Git-lhc/git-demo (master) $ git remote -v origin https://github.com/weishuoHH/git-demo.git (fetch) origin https://github.com/weishuoHH/git-demo.git (push)
团队内协作
跨团队合作
GitHub免密登录
#生成ssh免密登录命令 -t "以某种加密算法登录 -C "描述 ws199@DESKTOP-2N1I9JA MINGW64 ~ $ ssh-keygen.exe -t rsa -C weishuoHH@weishuo.com Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/ws199/.ssh/id_rsa): Created directory '/c/Users/ws199/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /c/Users/ws199/.ssh/id_rsa Your public key has been saved in /c/Users/ws199/.ssh/id_rsa.pub The key fingerprint is: SHA256:CVIbj1aIxRUz8t0m7WXpzBqwJ6RzNHze+B5dd5Jyiwk weishuoHH@weishuo.com The key's randomart image is: +---[RSA 3072]----+ | +=o*. | | ..oO = o . | | . = o O = + | | o . = X O . | | S E B O +| | o + O ++| | + + .| | . . | | . | +----[SHA256]-----+ ws199@DESKTOP-2N1I9JA MINGW64 ~ $ #通过ssh拉去远程库代码 ws199@DESKTOP-2N1I9JA MINGW64 /d/GIT/Git-Space/git.demo (master) $ git pull git@github.com:weishuoHH/git-demo.git master The authenticity of host 'github.com (20.205.243.166)' can't be established. ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? y Please type 'yes', 'no' or the fingerprint: yes Warning: Permanently added 'github.com' (ED25519) to the list of known hosts. From github.com:weishuoHH/git-demo * branch master -> FETCH_HEAD Already up to date.