git使用

来源:互联网 发布:慢镜头软件下载 编辑:程序博客网 时间:2024/05/01 05:22
repository存放项目代码,一个项目一个repository
fork
pull request -> merge
issue发现bug

基本修改操作
git status
git add *.php    添加到暂存区    git rm *.php    删除文件
git status
git commit -m 描述    添加到仓库
git status


设置
git config --global user.name 'username'
git config --global user.email 'mail.com'
git config --list

提示没有权限
.git/config
[remote "origin"]

    url = https://username:password@github.com/user/repo.git


远程操作
git clone url

修改流程同上
git add *.php
git commit -m 'some comment'
git push
    
分支
#git checkout -b issue53        创建分支.HEAD指针指向这个branch

相当于执行两条命令
#git branch issue53
#git checkout issue53

//issue53做修改
#git add|rm 等
#git commit -a -m "some comment"

//此时有个紧急问题要修改
#git checkout master    切换回master.但此时要保证暂存区或者工作目录里面还没有提交的修改
#git checkout -b hotfix31    紧急修补
#vim index.html
#git commit -a -m "some hot fix"
//合并
#git checkout master
#git merge hotfix31        //合并后hotfix31和master指向同一个指针
#git branch -d hotfix31    删除分支

//再返回issue53
#git checkout issue53

冲突
#git merge issue53
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.
#git status
#git mergetool    //解决冲突

#git status


合作基本流程

1.从master基础上创建分支,分支名要descriptive

#git checkout master先返回master
#git checkout -b refector-authentication

2.在分支上增加、修改、删除文件
#git add
#git rm 删除
#git mv 重命名
#git commit -m 'commit message' 提交到暂存区

3.Open pull requests

4.merge into master



0 0