When managing Git, if you don't want to submit the version before editing is complete, you have to change computers. what to do?
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-24 11:35:49
0
6
935

Using git archive can only export submitted versions. Unsubmitted ones will not work. .
After submission, export and then return to the previous version?
How should we do better?

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(6)
漂亮男人

Step 1: Pull a temporary branch

git checkout -b abc

Step 2: Submit on the temporary branch

git commit -m '临时分支'
git push

Step 3: Change the computer and checkout the temporary branch

git clone http://XXXXX.git
git checkout abc

Step 4: You can delete the abc branch

黄舟

Git is not svn. Git can develop with multiple branches, why can't it be submitted? Normal project management has at least one main branch and one release branch. Each developer has his own independent branch. After submission, it will be merged into the main branch after review by the specialist.

仅有的幸福

Cut a branch to store your modifications. You can submit the modified parts to this branch, change the computer and pull it down to continue development. After development, submit it to your own version library. Just delete your temporary branch after use

大家讲道理

1 Install the hard disk on the new computer
2 If the old and new computers can be used at the same time for a while, commit locally first, open the server on the old computer or use network sharing to share your code library, and clone the library on your old computer on the new computer. .
3 Create a new temporary branch and push it to the public server. After cloning on the new computer, delete the temporary branch on the public server.

过去多啦不再A梦

It is recommended to use the method above. Git is inherently distributed development. The cost of establishing a branch is very cheap. You can create branches at will.

Ty80

Give lz my method. This solution is not mainly for changing computers, but for not wanting to submit imperfect commits.
lz just wants to make the commit content more comprehensive. amend can solve it perfectly. This command is used to modify commit information

git commit --amend

General usage:

//edit code
git commit -m "temp commit"
//edit code
git commit --amend //修改commit信息
git push

In this way, you can submit it locally at any time. Each subsequent submission will modify the previous submission. When you are finally satisfied, push it to the remote.
For lz's situation, there is another point to note. After the first computer pushes and the second computer pulls&&--amend, the local commit and the remote commit are already different. At this time, you need to delete the remote branch and push it again. There are two methods

//第二台电脑修改code后
//删除远程分支并push(需要有权限)
git push -f
//如果没有权限,先删除远程分支,再push
git push origin :[branch-name]
git push
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template