git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How to Push a range of commits.

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Jun 30, 2010, 13:47 UTC
Message-ID
<20100630134758.GC30999@debian>
In-Reply-To
<AANLkTikOffJHjzd3iBOXm7Lt7uPzHGkR1kfWtxSd-F9S@mail.gmail.com>
Hi Mahesh,
Mahesh Vaidya writes:
Show 6 quoted lines
> On branch 'foobar' I have a range of contiguous  commits  say C1...C9,
> C1 being at HEAD / TOP.
> 
> If I push branch all 9 commits will make it to authoritative
> repository.  Is there a way to push a single commit (as C9 or C10 new
> commit) which is common change set between C1 .. C9

Do you want to squash all the commits into one commit and push that? If so, use the interactive rebase to squash them into one commit (in possibly another branch) and push that commit.

If you want to push just a few commits instead, create a new branch based on upstream, cherry-pick the commits you want into it and push it to the upstream branch. For example, if I have a branch `foo` tracking the upstream `origin/foo` and is ahead of the upstream by 10 commits, but I only want to push commit `bar`:

$ # In branch foo $ git checkout moo # New temporary branch $ git reset --hard origin/foo # Base it on upstream $ git cherry-pick bar $ git push origin +refs/heads/moo:refs/heads/foo $ # I think the "refs/heads" part can be omitted in the above command

-- Ram
Previous: Mahesh Vaidya
Message 2 of 2 in “How to Push a range of commits.”
  1. Mahesh VaidyaJun 30, 2010
  2. Ramkumar RamachandraJun 30, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.