我现在有个文件是a.js 但是本电脑上的a.js不是最新版,我想把他更新为最新版(不和我的这个版本合并,想得到纯粹的最新版)
伊谢尔伦2017-04-24 09:14:58
Let me give you a reliable answer. There is nothing wrong with adopting the answer, but it is not very relevant. It neither targets specific file operations nor uses an IDE.
Since I don’t have PHP Storm, I’ll use its big brother IntelliJ IDEA as an example.
In fact, you don’t need to delete the local file and get the latest version. What you have to do is: “Update any version of the specified file through history”, which of course includes the latest version. Then there is a premise that you have obtained the latest history record, which is git fetch
, and the corresponding IDE operation is:
Then let’s see how to update the version of the specified file.
The first step is to view the target file history
The second step is to find the version you want (whether it is a new version or an old version)
In addition, you can compare the file contents at this time to help pinpoint the version you want, as shown below (Compare... in the right-click menu)
Finally, use the Get menu item to get the specified version. The corresponding command is git checkout
As mentioned above, the integrated operation in the IDE is still very convenient. What is better than the command line is that the graphical instructions are quite clear. But - the command line is faster and more flexible. As long as your mind is clear enough, the command line is still more efficient.
In fact, if the process is smooth, half of them will be less likely to obtain specific versions for specific files. In most cases we do git pull
-> work -> commit -> work -> commit ... -> git pull
(maybe Resolve conflicts) -> git push
, every time you git pull
, you get the latest version of all files (equivalent to git pull
-> 干活 -> commit -> 干活 -> commit ... -> git pull
(maybe 解决冲突) -> git push
,每一次你 git pull
的时候,都等于拿到了所有文件的最新版本(等价于 git fetch
+ git merge/rebase
+ git merge/rebase
), so the above operations are often to roll back the version rather than get the latest version. Unless you just don’t want all versions to be updated, then my answer is what you need.
阿神2017-04-24 09:14:58
When you say submit, do you mean commit or push?
If you just want to delete a certain file, just delete it directly,
If it is a rollback commit, use revert to the version before you want to update, and then pull again
怪我咯2017-04-24 09:14:58
It has nothing to do with PhpStorm, it’s just basic git operations.
Delete the a file locally and pull the remote one down.
Delete a.jsrm -rf a.js
Update local git add .
git add .
git commit -m "deleted a.js"
git commit -m "deleted a.js"
Merge remote git fetch
git fetch
git checkout origin/master a.js
git checkout origin/master a.js
origin is the remote name
master is a remote branch
ringa_lee2017-04-24 09:14:58
In fact, it doesn’t need to be as complicated as Woody’s, right? ?
Just git checkout a.js
and that’s it