同版本安装文件和学习笔记,在https://github.com/sunasitA/skillMap.git 下
注册github账号和安装github客户端
创建一个仓库
Git安装和项目clone
git config –global user.name ‘’
git config –global user.email ‘’
git config –global http.proxy ‘XXX’
clone项目
git clone https://github.com/sunasitA/skillMap.git D:\skillmap
报错:fatal: HttpRequestException encountered.
remote: Repository not found.
fatal: repository ‘https://github.com/sunasitA/skillMap.git/’ not found
原因:skillMap仓库是private的,修改为public即可
修改方法:到github web界面-》setting-》拉到最下面-》修改为public
修改和提交本地文件到远程仓库
git add .
git commit –m ‘第一次提交’
git push -u origin master
此处报错:remote: Permission to sunasitA/skillMap.git denied to XXX.
原因电脑记了两个账号,要ssh到另一个,修改.git/cofig中的url
cd 到项目中,编辑 .git/cofig中的url
vim .git/config
将
[remote “origin”]
url = https://github.com/git的用户名/项目名称
的url改为
url = https://git的用户名@github.com/git的用户名/项目名称
即url = https://[email protected]/sunasitA/skillMap.git
再执行 git push -u origin master
输入账户,即可提交
撤销commit&push到远程仓库的提交
git add .
git commit -m '这是次恶意提交'
git push origin master
commit e51bb4de709f321c72c4dc8ab348c18665247959 (HEAD -> master, origin/master, origin/HEAD)
Author: sunasitA
Date: Fri Aug 23 17:25:55 2019 +0800
这是次恶意提交
commit c84f39c3f83db5692337a41a1a16bb07693aabfe
Author: sunasitA
Date: Fri Aug 23 10:20:13 2019 +0800
删除临时文件
git reset --hard退回到对应的版本,这边注意–hard会同步回退工作区文件,使用此命令要特别小心
git reset --hard e51bb4de709f321c72c4dc8ab348c18665247959
git log查看log
git log
commit c84f39c3f83db5692337a41a1a16bb07693aabfe (HEAD -> master)
Author: sunasitA
Date: Fri Aug 23 10:20:13 2019 +0800
删除临时文件
git push origin master –force
找回git reset –hard的版本
对于git reset –hard错误回退的代码,通过下面步骤找回。
(1) git reflog 找到git reset –hard的版本号
(2) git reset –hard (1)的id
(3) 将文件拷贝出来
(4) 替换本地工作区的文件
(5) git add .
git commit –m ‘’
git push origin master
什么是里程碑
完整可用版本的release。
分支开发和合并到master
Mster分支推送了新的没有测试的代码,而已发布的代码中存在一个bug,此时就要在已发布代码上创建一个分支。
git branch newBranch
git branch –a
git checkout newBranch
git add .
git commit
git push origin newBranch
git merge newBranch
git status
git push origin master
git log
newBranch的修改已经merge到master分支