天天看点

git常见用法

使用gitlab

(1)删除已有的公钥

git常见用法

使用命令:ssh-keygen.exe

私钥默认路径:/c/users/admin/.ssh/id_rsa

执行结果:

$ ssh-keygen.exe

generating public/private rsa key pair.

enter file in which to save the key (/c/users/admin/.ssh/id_rsa):

enter passphrase (empty for no passphrase):

enter same passphrase again:

your identification has been saved in /c/users/admin/.ssh/id_rsa.

your public key has been saved in /c/users/admin/.ssh/id_rsa.pub.

the key fingerprint is:

31:87:7e:23:33:8f:70:61:c9:29:66:a4:7e:2c:db:98 admin@admin-pc

the key's randomart image is:

+--[ rsa 2048]----+

|      .          |

|     o . +       |

|    . + x .      |

|   . + + =       |

|    o + s o      |

|     b o b .     |

|    e . . .      |

|                 |

+-----------------+

git常见用法

生成的公私玥:

git常见用法

 其中,id_rsa.pub 是公钥,需要拷贝id_rsa.pub内容到github中

git常见用法

 把上述内容拷贝到github中,如下图

git常见用法

注意:内容后面不能有空格和换行.

添加成功:

git常见用法

 这样就可以使用git bash直接clone 代码库勒.

使用命令:git clone [email protected]:aaa/bb_web.git

git常见用法

查看分支:

git branch -r

git常见用法

检出指定分支

git checkout origin/dev_revert_online

git常见用法

提交修改的文件(commit)

第一次提交时失败

git常见用法

解决方法:

先执行:git config --global user.email "[email protected]"

git常见用法

 然后就提交成功了

git常见用法

查看最后一个commit了的文件

git log -n 1

git常见用法

提交流程

git add index.html

git commit -m "test" *

git push

git常见用法

$ git checkout

your branch is up-to-date with 'origin/master-bug'.