1.下载git
2.创建版本库 新建一个文件夹gitstorage 进入 git init初始化 仓库创建好 生成.git文件
在github上创建一个仓库并与本地关联
首先在github上创建一个仓库与本地名称对应 gitstorage
然后 git remote add git_test https://github.com/hpwm/gitstorage.git(git_test 为远程仓库名 https方式)
使用ssh方式
git remote add git_test git@github.com:hpwm/gitstorage.git 这是会报错 选择yes后
git push -u git_test master 向远程仓库提交代码
如果报错
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
在cd ~/.ssh
ssh-keygen 生成公钥
cat ~/.ssh/id_rsa.pub 将公钥部署到github 上 测试是否添加成功 ssh -T git@github.com
会收到一条欢迎信息 参考(https://stackoverflow.com/questions/19660744/git-push-permission-denied-public-key)
然后重新push即可成功
先添加远程仓库
github上创建仓库 gitorigin
然后clone git clone git@github.com:hpwm/gitorigin.git
常用命令
git remote show [远程名(可选)] //查看远程仓库
git remote rm 远程仓库名 //删除远程仓库
git checkout -b dev 切换并创建一个分支 dev为分支名
git checkout dev 切换到指定分支
git branch 查看所以分支
git config --global user.name 'hpwm' 设置用户名
git config --global user.email '1278077589@qq.com' 设置邮箱
git merge dev 命令用于合并指定分支到当前分支
git branch -d dev 删除指定分支
url = https://github.com/hpwm/gitstorage.git
url = https://hpwm@github.com/hpwm/gitstorage.git
2.创建版本库 新建一个文件夹gitstorage 进入 git init初始化 仓库创建好 生成.git文件
在github上创建一个仓库并与本地关联
首先在github上创建一个仓库与本地名称对应 gitstorage
然后 git remote add git_test https://github.com/hpwm/gitstorage.git(git_test 为远程仓库名 https方式)
使用ssh方式
git remote add git_test git@github.com:hpwm/gitstorage.git 这是会报错 选择yes后
git push -u git_test master 向远程仓库提交代码
如果报错
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
在cd ~/.ssh
ssh-keygen 生成公钥
cat ~/.ssh/id_rsa.pub 将公钥部署到github 上 测试是否添加成功 ssh -T git@github.com
会收到一条欢迎信息 参考(https://stackoverflow.com/questions/19660744/git-push-permission-denied-public-key)
然后重新push即可成功
先添加远程仓库
github上创建仓库 gitorigin
然后clone git clone git@github.com:hpwm/gitorigin.git
常用命令
git remote show [远程名(可选)] //查看远程仓库
git remote rm 远程仓库名 //删除远程仓库
git checkout -b dev 切换并创建一个分支 dev为分支名
git checkout dev 切换到指定分支
git branch 查看所以分支
git config --global user.name 'hpwm' 设置用户名
git config --global user.email '1278077589@qq.com' 设置邮箱
git merge dev 命令用于合并指定分支到当前分支
git branch -d dev 删除指定分支
url = https://github.com/hpwm/gitstorage.git
url = https://hpwm@github.com/hpwm/gitstorage.git