I now have a file called a.js, but the a.js on this computer is not the latest version. I want to update it to the latest version (not to merge with this version of mine, to get the pure latest version)
Let me give you a reliable answer. There is nothing wrong with adopting the answer, but it is not quite relevant. It does not operate on specific files or use IDE.
Since I don’t have PHP Storm, I use its eldest brother IntelliJ IDEA as an example.
In fact, you don’t need to delete local files to get the latest version. What you need to do is “update any version of the specified file through historical records”, which of course includes the latest version. Then there is a premise that you have obtained the latest historical records, that is
git fetch, the corresponding IDE operation is:
Next, let’s look at how to update the version of the specified file.
The first step is to view the history of the target file
The second step is to find the version you want (both the new version and the old version are the same)
In addition, at this time, you can Compare the contents of the file, which is helpful to accurately locate the version you want, as shown in the following figure (the right-click menu has compare …)
Finally, use the Get menu item to obtain the specified version, and the corresponding command is
As mentioned above, the integration operation in IDE is still very convenient. The aspect 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 you have a clear mind, the command line is still more efficient.
In fact, if the process is smooth, half of it is less for specific documents to obtain specific versions. Most of the time we are
git pull-> work -> commit-> work -> commit …->
git pull(maybe resolves conflicts)->
git pushEvery time you
git pullAt the same time, it is equal to getting the latest version of all files (equivalent to
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 the versions to be updated, then my answer is what you need.