日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

git使用分支细节

發布時間:2025/3/19 编程问答 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 git使用分支细节 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、使用用戶名和密碼連接遠程服務器時需要注意用戶名

? ? ? ?如果使用相同git username選項時用戶名,認證一直失敗;這個用戶名要注意;但具體不清楚怎么尋找準確的,只是多嘗試幾個可能,就解決了問題;

?

二、創建分支時,上傳文件到分支需要使用如下命令:
?

? ? ? ?首先查看有沒有你新添的分支:
? ? ? ? ? git branch -a
(帶有*的分支是當前分支,如果是你需要提交的分支,后面就不需要進行下去了)

? ? ? ?如果沒有,就需要更新:
? ? ? ? ? git fetch origin --prune

? ? ? 然后需要切換到指定的分支,否則默認是master分支:

? ? ??git checkout -b branch_01

? ? ? ?最后提交:
? ? ?git push origin branch_01

?

三、創建ssh:

?1、To generate a new SSH key pair, use the following command:

? ? ? Git Bash on Windows / GNU/Linux / macOS:

? ? ? ? ssh-keygen -t rsa -C "your.email@example.com" -b 4096
? ? ? ?Windows:

? ? ? Alternatively on Windows you can download
? ? ?PuttyGen
? ? ?and follow this documentation article to generate a SSH key pair.
2,、you will be prompted to input a file path to save your SSH key pair to.

? ? If you don't already have an SSH key pair use the suggested path by pressing
? ?enter. Using the suggested path will normally allow your SSH client
? ?to automatically use the SSH key pair with no additional configuration.

3、If you already have a SSH key pair with the suggested file path, you will need
to input a new file path and declare what host this SSH key pair will be used
for in your .ssh/config file, see Working with non-default SSH key pair paths
for more information.


4、Once you have input a file path you will be prompted to input a password to
secure your SSH key pair. It is a best practice to use a password for an SSH
key pair, but it is not required and you can skip creating a password by
pressing enter.

NOTE: Note:
?If you want to change the password of your SSH key pair, you can use
?ssh-keygen -p <keyname>.


5、The next step is to copy the public SSH key as we will need it afterwards.

To copy your public SSH key to the clipboard, use the appropriate code below:

macOS:

pbcopy < ~/.ssh/id_rsa.pub
GNU/Linux (requires the xclip package):

xclip -sel clip < ~/.ssh/id_rsa.pub
Windows Command Line:

type %userprofile%\.ssh\id_rsa.pub | clip
Git Bash on Windows / Windows PowerShell:

cat ~/.ssh/id_rsa.pub | clip


6、The final step is to add your public SSH key to GitLab.

Navigate to the 'SSH Keys' tab in your 'Profile Settings'.
Paste your key in the 'Key' section and give it a relevant 'Title'.
Use an identifiable title like 'Work Laptop - Windows 7' or
'Home MacBook Pro 15'.

If you manually copied your public SSH key make sure you copied the entire
key starting with ssh-rsa and ending with your email.

Optionally you can test your setup by running ssh -T git@example.com
(replacing example.com with your GitLab domain) and verifying that you
receive a Welcome to GitLab message.

ssh -T git@example.com? ?這個example跟自己的郵箱無關,而是git代碼的域名有關;可以打開服務器網址,就可以看到域名;我總是輸入自己的郵箱名,導致一直出錯;而這里會加載sra的東西,如果前面生成ssh步驟設置了密碼,這里就會要求輸入密碼;(Once you have input a file path you will be prompted to input a password to secure your SSH key pair. It is a best practice to use a password for an SSH key pair, but it is not required and you can skip creating a password by pressing enter.)

三、使用:

注意:使用ssh的地址不同于原來的http地址:ssh是用git開頭的地址

git remote -v:如果是http開頭,說明仍然使用http的協議;

修改:git remote set-url origin? ssh地址;例如:

總結

以上是生活随笔為你收集整理的git使用分支细节的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。