我有一个设置(它需要这样),我将更新的文件同步到git存储库。当文件发生更改时会发生这种情况,并且在此同步过程中会忽略In [1055]: d.groupby((d.b != d.b.shift()).cumsum())['a'].diff()
Out[1055]:
0 NaN
1 -1.0
2 NaN
3 1.0
4 NaN
Name: a, dtype: float64
文件夹。
所以
有些时候,我需要根据上游更新In [1056]: (d.b != d.b.shift()).cumsum()
Out[1056]:
0 1
1 1
2 2
3 2
4 3
Name: b, dtype: int32
上的git,所以我使用的是.git
。为此目的做了哪些工作。
但是,我希望能够检测到,如果这实际更新了任何文件。 换句话说,如果客户端文件同步与上游git repo是最新的,我想检测它..
我能找到的最接近的方法就是回答here使用server
之类的东西。问题是它显示了更改,即使文件和内容已经存在......
使用测试用例
更新git fetch --all && git reset --hard origin/branchname
答案 0 :(得分:1)
您可以在diff
之前看到origin/master
和HEAD
之间的reset
。
$ git fetch --all
$ git diff HEAD..origin/master # see what is in origin/master that is not in HEAD (local latest commit)
$ git diff origin/master..HEAD # see what is in HEAD that is not in origin/master
# If local uncommitted changes exist (tracked by git)
$ git diff origin/master
# for untracked/new files, one way is to use '-N' flag with 'git add' command
$ git add -N .
$ git diff origin/master
有关'-N'的更多信息: $ git add --help
-N, --intent-to-add Record only the fact that the path will be added later. An entry for the path is placed in the index with no content. This is useful for, among other things, showing the unstaged content of such files with git diff and committing them with git commit -a.
答案 1 :(得分:0)
让服务器在收发后执行结帐(通过SHA),并使用git push
执行第1步。 "文件同步(忽略.git
)"而只有当事情发生变化时,完全推送已提交的更改才会执行此操作。