Git安装的操作笔记(个人操作记录)
Git命令:
git add . 将本地文件增加到暂存区
git commit 将暂存区的内容提交到本地仓库(本地分支,默认master分支)
git push 将本地仓库的内容推送到远程仓库(远程分支)
git pull 将远程仓库的内容拉取到本地仓库
1.Git下载地址:https://gitforwindows.org/
2.安装配置git:
安装时:Use git from git bash only ...... 其他默认下一步
配置path: C:\JavaSoftware\Git\bin (跟jdk,maven环境变量配置类似)
配置git:
右键 —Git Bash Here
git config --global user.name "dxchen"
git config --global user.email "[email protected]"
上面配置成功后可查看:c:\Users\小小新\.gitconfig文件如下
3.搭建git服务器(远程仓库):统一的托管网站https://github.com
为了在本地和远程仓库之间进行免**登陆,可以配置ssh
ssh:本地—远程关联配置(先在本地配置,发送给远程),如下操作:
a.先本地生成ssh: ssh-****** -t rsa -C [email protected]
输入上面命令一直按回车,邮箱号用自己的github邮箱,出现上图表示**生成成功
b.发送给远程:
2.点击settings设置
3.点击进入SSH and GPG keys 点击New SSH key
4.拷贝刚生成的公钥(打开文件c:\Users\小小新\.ssh\id_rsa.pub,全部复制)
拷贝到下图key中,最后不能有空格和回车,title任意填写,
点击Add SSH key成功保存,显示如下
4.测试连通性
命令:ssh -T [email protected] -----> yes
如果本地多了个C:\Users\小小新\.ssh\known_hosts,连通成功
如果失败,多尝试几次,检查回车符
3.git使用:
在本地新建git项目
在项目根目录 右键点击Git Bash Here
输入命令git init 根目录文件下会生成.git文件目录
在远程新建git项目
生成
https://github.com/daoxinchen/mygitremote.git
[email protected]:daoxinchen/mygitremote.git
本地项目和远程项目关联
git remote add origin [email protected]:daoxinchen/mygitremote.git
发布项目
git add . 将文件加到暂存区
git commit -m "注释内容"
git push -u origin master
下载项目
git clone [email protected]:daoxinchen/mygitremote.git
提交项目
git add .
git commit - m "提交到分支"
git push origin master
更新
git pull
4.git在eclipse中使用
目前的eclipse基本都支持git,如果不支持,则到eclipse marktplace搜索git安装
配置:
a.Windows——Preferences——Team——configuration 配置邮箱和用户名
b.general - network - ssh2选中生成的ssh目录
发布项目
1.右键项目——Team——share project
点Create创建本地仓库mygit
2.右键项目——Team——add to index 加入到缓存区
3.右键项目——Team——commit 提交到本地分支
4.将项目推送到远程 右键—team—remote—push
勾选Store in Secure Store
选中之后点击Add Spec,继续Next-Finish
提交 :
team - add to index
team - commit
team - push
commit and push 和 commit 按钮的区别:
commit 按钮:不能单独的Push某一个文件,只能Push整个项目
commit and push :可以单独Push某一个文件
下载:
import -clone 输入 https/ssh 的唯一标识符
更新:
team - remote -repositories -pull
git冲突的解决
发现冲突进入同步试视图 右键-team-synchronized...
解决:
添加到本地暂存区 add to index
提交到本地分支 commit
修改冲突:直接修改或者merge tool
git多个人,团队写作开发
github中,该项目--setting
增加合作者:Collaborators 加入合作者:github 全名或邮箱
发送邀请链接
合作伙伴:打开该连接 接收邀请 clone项目 修改 add \commit\push
编写粗略,仅仅个人使用,后续慢慢修正