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地址;例如:
總結
- 上一篇: 将每个字典一行一行的添加到pd.Data
- 下一篇: git只添加指定类型的文件的.gitig