我在文件夹public_html中有一个脚本,我想仅跟踪和修改其中的某些目录(递归)。内容示例:
- 公共html/文件1.php 公共html/文件2.php
- public_html/模板/自定义/file3.php
- public_html/模板/自定义/dir1/file4.php
- public_html/模板/自定义/dir2/file5.php
- public_html/模块/自定义/file6.php
- public_html/模块/自定义/dir3/file7.php
- public_html/模块/自定义/dir4/file8.php
基本上,我想忽略除以下目录及其全部内容之外的所有目录和文件:
- public_html/模板/自定义/dir1/
- public_html/模块/自定义/dir1/
我所做的如下:
git add public_html/template/custom/dir1
git add public_html/module/custom/dir3
但当我推:
error: failed to push some refs to 'git.gitdomain.com:abc/reponame.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
有任何想法吗?
答案1
刚刚发现我做错了什么,这个方法起了作用:
git remote add origin [email protected]:group/reponame.git
git add public_html/templates/custom/dir1/*
git add public_html/module/custom/dir1/*
git commit -m "first commit"
git push origin master