Suppose I have the following commits in my local branch,
the oldest is 17081fa
, the latest is 12ba64e
How could I push these commits to remote git server one by one.
Take an example,
I don't want to push all local commits at once.
the push order should be
17081fa -> 30854d2 -> ... -> 12ba64e
These commits are ready to push to server, but need to be pushed one by one,
I need to know what's the command can let me do that way, thanks
* 12ba64e
* 0fdf1a6
* 75428a3
* 00f837f
* da9d16d
* 3f34af9
* b6066e9
* cdf2dbf
* 0d5cc8b
* db8744c
* df564b9
* 30854d2
* 17081fa
Conclusion. To push to a specific branch in Git, open Git Bash and navigate to the directory from which you want to push files to the remote branch. Then, initialize the directory using the “$ git init” command. Next, run the “$ git add .” command to add all files.
If you run the simple command git push , Git will by default choose two more parameters for you: the remote repository to push to and the branch to push. By default, Git chooses origin for the remote and your current branch as the branch to push.
When comparing Git pull vs fetch, Git fetch is a safer alternative because it pulls in all the commits from your remote but doesn't make any changes to your local files. On the other hand, Git pull is faster as you're performing multiple actions in one – a better bang for your buck.
You can simply specify the full refspec when pushing:
git push origin 17081fa:branchname
git push origin 30854d2:branchname
# etc
If you want to automate it a bit, you could write a litte shell loop which waits for your keypress:
for hash in $(git rev-list 17081fa^..12ba64e); do
read -p "Pushing $hash. Press return to continue.";
git push origin $hash:branchname;
done
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