Git configuration
Git installation and configuration
1. Git installation
- Windows
– Download the installer from https://git-scm.com/download/win
– git-bash.exe
2. Git configuration
$ git config --global user.name <name>
$ git config --global user.email <email>
$ git config --global color.ui true
修改:
git config --global user.name "Your Name"
git config --global user.email you@example.com
git commit --amend --reset-author
$ git config -l
- Generate SSH key pair for authentication
$ ssh-keygen (always Enter)
PS C:\Users\yujing.mu\.ssh> ls
Directory: C:\Users\yujing.mu\.ssh
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11/25/2019 10:34 AM 1679 id_rsa
-a---- 11/25/2019 10:34 AM 405 id_rsa.pub
-a---- 1/20/2020 5:03 PM 639 known_hosts
- Put the ‘config’ (attachment) file to C:\Users\(username)\.ssh
- PS C:\Users\yujing.mu\.ssh> ls
Directory: C:\Users\yujing.mu\.ssh
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11/26/2019 6:19 PM 59 config
-a---- 11/25/2019 10:34 AM 1679 id_rsa
-a---- 11/25/2019 10:34 AM 405 id_rsa.pub
-a---- 1/20/2020 5:03 PM 639 known_hosts
- Add config file under ~/.ssh for Windows
-
- Add config file under ~/.ssh for Windows
– Content is as below:

- Upload the SSH public key to Gerrit
– cat ~/.ssh/id_rsa.pub

– Login Gerrit server (http://10.100.24.7:8080)
– Click Down Arrow besides your name
– Click “Settings
– Go to “SSH Public Keys” sub-tab of “Settings”
– Click “Add Key…”
– Paste the SSH public key
– Click “Add” button
- Clone remote repository to local working directory
$ git clone <url> clone an existing repository
Note: git clone ssh://ldap_account@xxxxx:29418/xxx/func/src && scp -p -P 29418 ldap_account@xxxxxx:hooks/commit-msg src/.git/hooks/
Git clone failed due to filename too long
Resolution: git config --global core.longpaths true

solution:
Step1:
curl -Lo `git rev-parse --git-dir`/hooks/commit-msg http://name@xxxxxx:8080/tools/hooks/commit-msg; chmod +x `git rev-parse --git-dir`/hooks/commit-msg
Step2:
git commit --amend --no-edit
Step3:
git push origin HEAD:refs/for/master
浙公网安备 33010602011771号