<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=Git%2FBranch</id>
	<title>Git/Branch - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=Git%2FBranch"/>
	<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=Git/Branch&amp;action=history"/>
	<updated>2026-06-17T19:05:40Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://aznot.com/index.php?title=Git/Branch&amp;diff=9946&amp;oldid=prev</id>
		<title>Kenneth: Created page with &quot;== Create new branch from last 10 commits ==   https://stackoverflow.com/questions/50992188/how-to-push-a-shallow-clone-to-a-new-repo  &lt;pre&gt; # First, shallow-clone the old repo to the depth we want to keep git clone --depth=50 https://...@bitbucket.org/....git  # Go into the directory of the clone cd clonedrepo  # Once in the clone&#039;s repo directory, remove the old origin git remote remove origin  # Store the hash of the oldest commit (ie. in this case, the 50th) in a var...&quot;</title>
		<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=Git/Branch&amp;diff=9946&amp;oldid=prev"/>
		<updated>2026-06-17T05:35:53Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Create new branch from last 10 commits ==   https://stackoverflow.com/questions/50992188/how-to-push-a-shallow-clone-to-a-new-repo  &amp;lt;pre&amp;gt; # First, shallow-clone the old repo to the depth we want to keep git clone --depth=50 https://...@bitbucket.org/....git  # Go into the directory of the clone cd clonedrepo  # Once in the clone&amp;#039;s repo directory, remove the old origin git remote remove origin  # Store the hash of the oldest commit (ie. in this case, the 50th) in a var...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Create new branch from last 10 commits ==&lt;br /&gt;
&lt;br /&gt;
 https://stackoverflow.com/questions/50992188/how-to-push-a-shallow-clone-to-a-new-repo&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# First, shallow-clone the old repo to the depth we want to keep&lt;br /&gt;
git clone --depth=50 https://...@bitbucket.org/....git&lt;br /&gt;
&lt;br /&gt;
# Go into the directory of the clone&lt;br /&gt;
cd clonedrepo&lt;br /&gt;
&lt;br /&gt;
# Once in the clone&amp;#039;s repo directory, remove the old origin&lt;br /&gt;
git remote remove origin&lt;br /&gt;
&lt;br /&gt;
# Store the hash of the oldest commit (ie. in this case, the 50th) in a var&lt;br /&gt;
START_COMMIT=$(git rev-list master|tail -n 1)&lt;br /&gt;
&lt;br /&gt;
# Checkout the oldest commit; detached HEAD&lt;br /&gt;
git checkout $START_COMMIT&lt;br /&gt;
&lt;br /&gt;
# Create a new orphaned branch, which will be temporary&lt;br /&gt;
git checkout --orphan temp_branch&lt;br /&gt;
&lt;br /&gt;
# Commit the initial commit for our new truncated history; it will be the state of the tree at the time of the oldest commit (the 50th)&lt;br /&gt;
git commit -m &amp;quot;Initial commit&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Now that we have that initial commit, we&amp;#039;re ready to replay all the other commits on top of it, in order, so rebase master onto it, except for the oldest commit whose parents don&amp;#039;t exist in the shallow clone... it has been replaced by our &amp;#039;initial commit&amp;#039;&lt;br /&gt;
git rebase --onto temp_branch $START_COMMIT master&lt;br /&gt;
&lt;br /&gt;
# We&amp;#039;re now ready to push this to the new remote repo... add the remote...&lt;br /&gt;
git remote add origin https://gitlab.com/....git&lt;br /&gt;
&lt;br /&gt;
# ... and push.  We don&amp;#039;t need to push the temp branch, only master, the beginning of whose commit chain will be our &amp;#039;initial commit&amp;#039;&lt;br /&gt;
git push -u origin master&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== keywords ==&lt;/div&gt;</summary>
		<author><name>Kenneth</name></author>
	</entry>
</feed>