After copying the project to a new computer, operations such as pulling code/viewing historical submission records cannot be performed through git.

Project scenario:

将项目代码整体打包到新环境(新电脑), 在idea/pycharm下载好git相关插件并打开项目之后, 通过git拉取代码失败(gitlab/git/gtee)


Problem Description

Recently, due to work reasons, I need to migrate the code on my computer to a new computer. However, after configuring the idea and git plug-in, I opened the project and found that I could not view the previous submission records, even if I clicked refresh.

Insert image description here
And after updating the code, the lower right corner will prompt that the update failed.

Insert image description here

I have used the most brainless method before: to find the branch address of the project, and then git clonere-pull the code . Although it can be successful, it will be very troublesome when there is too much code in the project, and there is no real solution to the problem. Therefore, If you want to completely solve the problem, you still need to do your own research...


Cause Analysis:

Translate the above prompt:

Due to an error, the working tree cannot be checked for unmerged files. A suspicious ownership issue was detected in the 'C:/code/idea_code/sxd_zk/emq-mqtt-js' repository. The owner of the directory is 'S-1-5-32-544' but the current user is 'S-1-5-21-3807661080-2757311255-2536245887-1001'. To add an exception for this directory, call: git config --global --add safe.directory C:/code/idea_code/sxd_zk/emq-mqtt-js.

We can know from the prompt information that although we have migrated the directory, the local warehouse information is still the original computer S-1-5-32-544. Our new computer S-1-5-21-3807661080-2757311255-2536245887-1001will definitely fail to update using the original warehouse information. Therefore, use the git command to update the global code for this branch. Add a safe local warehouse directorygit config --global --add safe.directory 代码仓库地址


solution:

  1. Execute the git command to add the current directory as a new local warehouse

    git config --global --add safe.directory 项目新地址
    

    Insert image description here
    ps: If you have not logged in before, the login page will pop up here. You can proceed with subsequent operations after successful login.

  2. After successfully executing the command, update the code again, and be sure to choose to merge the incoming changes into the current branch .
    Insert image description here

  3. Click the refresh button of the git submission record in the problem description chapter again , and you can see that the log history has been restored. The code update submission function has also been restored.
    Insert image description here

Reflection:

As you can see, the current IDE is very smart. Even how to operate is informed in the prompt information. Therefore
, if you encounter some external environment problems during development, you should pay more attention to the prompt information of the IDE tool, maybe like here The same problems you encounter can be solved through prompt messages.

Guess you like

Origin blog.csdn.net/qq_43371556/article/details/131533562