在phpstorm里如何删掉本地的某一文件重新获取最新的github里面的最新版本
PHPz
PHPz 2017-04-24 09:12:58
0
4
822

我现在有个文件是a.js 但是本电脑上的a.js不是最新版,我想把他更新为最新版(不和我的这个版本合并,想得到纯粹的最新版)

PHPz
PHPz

学习是最好的投资!

reply all(4)
伊谢尔伦

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.

阿神

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

刘奇

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.js
rm -rf a.js
Update local
git add .git add .
git commit -m "deleted a.js"git commit -m "deleted a.js"
Merge remote
git fetchgit fetch
git checkout origin/master a.jsgit checkout origin/master a.js

origin is the remote name
master is a remote branch

左手右手慢动作

In fact, it doesn’t need to be as complicated as Woody’s, right? ?
Just git checkout a.js and that’s it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template