简体   繁体   English

提交显示未添加文件的更改

[英]Commit showing changes on file that was not added

I have a branch called branchA. 我有一个名为branchA的分支。 I've been doing some work on it and ran git pull master to update it with all the changes in the master branch. 我一直在做一些工作,然后运行git pull master来更新master分支中的所有更改。 Within branchA, I want to commit two files and they're called py_file1.py and details.sql. 在branchA中,我要提交两个文件,它们分别称为py_file1.py和details.sql。 So I do the following: 因此,我执行以下操作:

git add py_file1.py
git add details.sql
git commit

I then pushed the commit to my remote branch on github. 然后,我将提交推送到github上的远程分支。 When I went to checkout the commit on github, I saw both py_file1.py and details.sql, but it was also showing the changes made on py_file2.py that occurred when I pulled from master. 当我去检查github上的提交时,我看到了py_file1.py和details.sql,但是它也显示了当我从master那里拉出时对py_file2.py所做的更改。 If I never added py_file2.py to be tracked, why are those changes appearing on my commit? 如果我从未添加要跟踪的py_file2.py,为什么这些更改会在我的提交中出现?

py_file2.py was indeed tracked, in the master branch. 确实在master分支中跟踪了py_file2.py Therefore when you merged master into branchA , it became tracked in branchA as well. 因此,当您将master合并到branchA ,它也将在branchA被跟踪。

That being said, are you saying that it was showing py_file2.py as changed in the same commit as as when you added py_file1.py and details.sql ? 就是说,您是说它显示的py_file2.py与添加py_file1.pydetails.sql时的提交相同吗? If that was the case, then you probably pulled, got some conflicts, resolved them, but did not commit before you added those two files. 如果真是这样,那么您很可能拉扯了一些冲突,将其解决,但是添加这两个文件之前没有提交。 In general, you don't want to do that; 通常,您不想这样做; always commit your merge first before doing any non-merge changes. 在进行任何非合并更改之前,请始终先提交合并。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM