Is there a way to combine git commands atomically (not through a shell)?

Say I want to do this:

git checkout featureBranch git rebase master 

If I want to combine two shell commands that I can do:

 git checkout featureBranch && git rebase master 

However, this is not atomic. If for some reason the git checkout command does not work, the working directory will not be in the same state as before, or in the final expected state. In addition, other processes, such as my IDE, may see an intermediate state between the two teams.

Does git provide a way to combine two actions atomically?

I do not need file system level atomicity. That is, if the combined action requires changing 10 files in the working directory, it is normal if other processes can observe these 10 changes individually.

Edit: The above two commands are for illustration purposes only. In addition, it may be 3 or more teams that need to be bound.

+5
source share
1 answer

According to man git-rebase these commands can be combined:

 If <branch> is specified, git rebase will perform an automatic git checkout <branch> before doing anything else. Otherwise it remains on the current branch. 

So you can just run:

 git rebase master remoteBranch 

However, there is no general solution.

+4
source

All Articles