git多人合作开发同一个分支

1、cocopod安装 

我在本地操作git add;git commit;git pull;git push

git status

git checkout -fc

git branch

git checkout branch_name  查看branch_name 分支

git checkout -b branch_name 创建并查看branch_name分支

git checkout -b branch_name origin  以远端分支为蓝本创建并查看branch_name分支

git rm -r --cached . 清楚缓存

扫描二维码关注公众号,回复: 13546606 查看本文章

执行git lfs ls-files应该能看见东西

git lfs track “* .a” 可以是项目根目录文件路劲:

git add .gitattributes

git add demo.a
git commit -m "提交.a大文件"
git push或者git lfs push origin master 上传大文件

git push -u origin master

对方 git pull 就可以看到修改的文件了

详细的 首先我这里下载好了对方的代码项目(xcode自带的check out),当我做了修改,要提交的时候,首先要进入项目所在文件根目录下,然后执行"git add ."然后执行git commit命令,如果有冲突提示 CONFLICT 这时 你就要收到那个修改冲突文件,或者你可以在当前文件夹下执行ls -al查看所有文件,然后看到".gitignore"文件,这时 你可以讲不必要修改的文件通过执行vi .gitignore命令进行添加 ,添加完之后执行wq  再次执行git add .命令 然后git commit -m "我提交了文件在 2014年11月12日下午8:00",然后 git push origin master ,没有error或者fatal提示的话  这就表明提交成功了;

当输入命令:

git push origin master

出现

failed to push some refs to 'https://github.com/originURL/file.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

原因:自己分支版本低于主版本

git push -u origin master-f

出现 error: The following untracked working tree files would be overwritten by merge:

输入 git clean -d -fx

原因:会删除掉没有add到仓库的文,本质上就是操作仓库中没有被追踪的本地文件。

$ git clean -f -n # 1

$ git clean -f # 2

$ git clean -fd # 3

$ git clean -fX # 4

$ git clean -fx # 5

(1): 选项-n将显示执行(2)时将会移除哪些文件。

(2): 该命令会移除所有命令(1)中显示的文件。

(3): 如果你还想移除文件件,请使用选项-d。

(4): 如果你只想移除已被忽略的文件,请使用选项-X。

(5): 如果你想移除已被忽略和未被忽略的文件,请使用选项-x。

需求:原有仓库地址下的项目代码不再需要了,此时重新构建项目并上传原有仓库地址:

1、删除本地仓库代码并commit->push

2、移至新项目目录路径下更换仓库地址

4、git remote show origin 

5、在这里如果新项目有远程仓库地址,执行步骤6,如果没有远程仓库地址直接执行步骤7

6、git remote rm origin

7、git remote add origin https://<#原有的仓库地址#>

8、git pull

9、git push -u origin master -f

git checkout -b devBranch origin/devBranch 创建远程新分支
git branch -a 远程和本地分支列表
git checkout --merge <branch>同步(合并)到切换的分支下branch
git merge 合并
git stash
git checkout -p <branch>比较两个分支间的差异内容
git reset --hard e377f60e28c8b84158回滚到指定的版本
git reset --hard commit_id 退到/进到 指定commit的sha码
git branch -D <branch>
git 修改当前的project的用户名的命令为:
git config user.name 你的目标用户名;
git 修改当前的project提交邮箱的命令为:
git config user.email 你的目标邮箱名;
退出git quote 使用control + C 退出当前编译模式
git stash 暂存
如果有新添加的文件,那么就需要添加 -a 参数(如,git stash -a 或 git stash save -a "注释"),或先 git add . 然后再使用 git stash 或 git stash save "注释" 来暂存修改
查看有多少个修改暂存,可以使用 git stash list 来查看 stash 列表

1、git配置远程地址

git remote add origin url ,其中url为远程仓库地址。

2、git删除远程地址

git remote rm origin

查看远程仓库地址信息

git remote -v 

git pull origin master –allow-unrelated-histories

该选项可以合并两个独立启动仓库的历史

Mac 下使用brew install 报错:

用sudo执行brew命令,必须将 /usr/local/bin/brew 改成root
localhost:infer-osx-v0.6.0 admin$ sudo brew install opam Error: Cowardly refusing to `sudo brew install' You can use brew with sudo, but only if the brew executable is owned by root. However, this is both not recommended and completely unsupported so do so at your own risk.

用sudo执行brew命令,必须将 /usr/local/bin/brew 改成root

sudo chown root:wheel /usr/local/bin/brew

warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777

解决:sudo chmod go-w /usr/local/bin

这里可以借助 git操作教程来进一步学习,或者阅读以下小编推荐的博客进行学习阅读。

//基本git命令符 详细使用

http://blog.csdn.net/gemmem/article/details/7290125

//初学者  git

http://blog.chinaunix.net/uid-24060800-id-3480026.html

//git 密钥操作

http://blog.csdn.net/xuhaiyan8825/article/details/7707285

http://862123204-qq-com.iteye.com/blog/1683315

注:以上网址都属转载篇,仅供学习用,路人甲请勿喷。

 

code奸我千百遍,我待code如初见

猜你喜欢

转载自blog.csdn.net/chungeshihuatian/article/details/42002295
今日推荐