问题
For example, if I am pushing master
to a remote repo and it's taking a while, is it safe to open another terminal and do git checkout secondbranch
so I can start working again? Is the original process doing the push going to be disrupted by the new checkout?
回答1:
It should be safe, because push is reading from your local repo and writing to the remote, and checkout is reading from your local repo and writing to your workspace.
Nice visualization of what-goes-where: http://www.ndpsoftware.com/git-cheatsheet.html#loc=local_repo;
回答2:
Yes, it is safe.
Push is separate concept from the working directory and the checked-out branch. You can actually push and fetch from the .git directory of your repo (or any bare repo for that matter). That shows, at a high level, the two aspects of the application are well isolated.
With that being said, always make backups of your data.
来源:https://stackoverflow.com/questions/11715379/is-it-safe-to-checkout-a-new-git-branch-during-the-push-of-a-current-branch