Say, I want to do this:
git checkout featureBranch
git rebase master
If I want to combine the two "shell" commands I can do:
git checkout featureBranch && git rebase master
However, that is not atomic. If the git checkout
command fails for some reason, the working directory will not be in the same state as before, nor in the final expected state. Also, other processes, such as my IDE, might be able to see the intermediate state between the two commands.
Does git
provide a way to combine two actions atomically?
I don't need complete file-system level atomicity. That is, if the combined action requires 10 files in the working directory to be changed, it is okay if other processes can observe these 10 changes individually.
Edit: The above two commands are just for illustration. Also, it could be 3 or more commands that need to be chained.
All you have to do is to create a file and add all your commands in the same sequence in which you want to execute. That's it!
Git commit -m The -m option of commit command lets you to write the commit message on the command line. This command will not prompt the text editor. It will run as follows: $ git commit -m "Commit message."
According to the man git-rebase
these commands can be merged:
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 could just run:
git rebase master remoteBranch
However there is no general solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With