");transition-property:opacity;transition-duration:.7s;transition-timing-function:cubic-bezier(.4,0,.2,1)}main figure:has(pre) button:after{opacity:0;background-image:url("data:image/svg+xml, ");transition-property:opacity;transition-duration:.5s;transition-timing-function:cubic-bezier(.4,0,.2,1)}main figure:has(pre) button:active:before{opacity:0;transition-duration:0s}main figure:has(pre) button:active:after{opacity:.6;transition-duration:0s}main figure:has(pre):hover button{opacity:1}main li{margin-left:2.25rem}main ul li{list-style-type:square}aside{font-size:.94rem}aside a{--tw-text-opacity:1;color:rgb(27 61 157/var(--tw-text-opacity))}aside a:hover{filter:drop-shadow(0 0 .5em #1b3d9d59)}aside p{margin-bottom:.5rem;line-height:1.55}*,:before,:after{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }#hamburger-menu-label{cursor:pointer;padding:1.25rem 1rem}@media (min-width:768px){#hamburger-menu-label{display:none}}#hamburger-menu-label span{position:relative}#hamburger-menu-label span,#hamburger-menu-label span:before,#hamburger-menu-label span:after{--tw-bg-opacity:1;background-color:rgb(115 115 115/var(--tw-bg-opacity));width:1.5rem;height:2px;transition-property:all;transition-duration:.2s;transition-timing-function:cubic-bezier(.4,0,.2,1);display:block}#hamburger-menu-label span:before,#hamburger-menu-label span:after{--tw-content:"";content:var(--tw-content);width:100%;height:100%;position:absolute}#hamburger-menu-label span:before{top:-7px}#hamburger-menu-label span:after{top:7px}#hamburger-menu:checked+#hamburger-menu-label span{background-color:#0000}#hamburger-menu:checked+#hamburger-menu-label span:before{top:0;transform:rotate(45deg)}#hamburger-menu:checked+#hamburger-menu-label span:after{top:0;transform:rotate(-45deg)}#top-menu{clear:both;--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity));flex-direction:column;height:0;transition-property:height;transition-duration:.3s;transition-timing-function:cubic-bezier(.4,0,.2,1);display:flex;overflow:hidden}@media (min-width:768px){#top-menu{float:right;flex-direction:row;height:auto}}#top-menu a{text-align:center;padding:1.25rem 0;display:block}@media (min-width:768px){#top-menu a{padding:0 1rem}#top-menu a:last-child{padding-right:0}}#hamburger-menu:checked~#top-menu{height:100vh}@media (min-width:768px){#hamburger-menu:checked~#top-menu{height:auto}}.glow{z-index:10;position:relative}.glow:hover{opacity:1;--tw-drop-shadow:drop-shadow(0 0 #0000);filter:var(--tw-blur)var(--tw-brightness)var(--tw-contrast)var(--tw-grayscale)var(--tw-hue-rotate)var(--tw-invert)var(--tw-saturate)var(--tw-sepia)var(--tw-drop-shadow)}.glow:before{content:"";z-index:-10;--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity));position:absolute;inset:0}.glow:after{--glow-scale-min:.95;--glow-scale-max:1;content:"";z-index:-20;background-image:linear-gradient(120deg,var(--tw-gradient-stops));--tw-gradient-from:#1b3d9d var(--tw-gradient-from-position);--tw-gradient-to:#e4165c var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to);opacity:0;--tw-blur:blur(24px);filter:var(--tw-blur)var(--tw-brightness)var(--tw-contrast)var(--tw-grayscale)var(--tw-hue-rotate)var(--tw-invert)var(--tw-saturate)var(--tw-sepia)var(--tw-drop-shadow);transition-property:opacity;transition-duration:.7s;transition-timing-function:cubic-bezier(.4,0,.2,1);animation:1.5s ease-in-out infinite alternate paused grow;position:absolute;inset:0}.glow:hover:after{opacity:.6;animation-play-state:running}.glow-sm:after{--glow-scale-min:.87;--glow-scale-max:.92}@keyframes grow{0%{transform:scale(var(--glow-scale-min))}to{transform:scale(var(--glow-scale-max))}}.chip{text-wrap:nowrap;--tw-bg-opacity:1;background-color:rgb(245 245 245/var(--tw-bg-opacity));--tw-text-opacity:1;color:rgb(82 82 82/var(--tw-text-opacity));border-radius:9999px;padding:.125rem .5rem;transition-duration:.7s;display:inline-block}.chip:last-child{margin-right:0}a.chip:hover{filter:drop-shadow(0 0 .7em #0000001f)}div:has(>input){position:relative}input:where(:not([type])),[type=email]{--tw-border-opacity:1;border-color:rgb(209 213 219/var(--tw-border-opacity));caret-color:#2563eb;--tw-shadow:0 1px 2px 0 #0000000d;--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);border-radius:.125rem;width:100%;padding-top:.375rem;padding-bottom:.375rem;padding-left:2.5rem;transition-property:box-shadow;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}input:where(:not([type])):focus,[type=email]:focus{border-color:#1b3d9d66;box-shadow:0 0 12px 3px #93c5fd7f}input:where(:not([type]))+svg,[type=email]+svg{--tw-translate-y:-50%;--tw-translate-x:-50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y))rotate(var(--tw-rotate))skew(var(--tw-skew-x))skewY(var(--tw-skew-y))scaleX(var(--tw-scale-x))scaleY(var(--tw-scale-y));--tw-text-opacity:1;color:rgb(156 163 175/var(--tw-text-opacity));font-size:1.125rem;line-height:1.75rem;position:absolute;top:50%;left:1.38rem}input:where(:not([type])):focus+svg,[type=email]:focus+svg{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity));opacity:.6}:not(figure)>button{z-index:10;position:relative}:not(figure)>button:hover{opacity:1;--tw-drop-shadow:drop-shadow(0 0 #0000);filter:var(--tw-blur)var(--tw-brightness)var(--tw-contrast)var(--tw-grayscale)var(--tw-hue-rotate)var(--tw-invert)var(--tw-saturate)var(--tw-sepia)var(--tw-drop-shadow)}:not(figure)>button:before{content:"";z-index:-10;--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity));position:absolute;inset:0}:not(figure)>button:after{--glow-scale-min:.95;--glow-scale-max:1;content:"";z-index:-20;background-image:linear-gradient(120deg,var(--tw-gradient-stops));--tw-gradient-from:#1b3d9d var(--tw-gradient-from-position);--tw-gradient-to:#e4165c var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to);opacity:0;--tw-blur:blur(24px);filter:var(--tw-blur)var(--tw-brightness)var(--tw-contrast)var(--tw-grayscale)var(--tw-hue-rotate)var(--tw-invert)var(--tw-saturate)var(--tw-sepia)var(--tw-drop-shadow);transition-property:opacity;transition-duration:.7s;transition-timing-function:cubic-bezier(.4,0,.2,1);animation:1.5s ease-in-out infinite alternate paused grow;position:absolute;inset:0}:not(figure)>button:hover:after{opacity:.6;animation-play-state:running}:not(figure)>button:after{--glow-scale-min:.87;--glow-scale-max:.92}:not(figure)>button{--tw-bg-opacity:1;background-color:rgb(228 22 92/var(--tw-bg-opacity));text-transform:uppercase;letter-spacing:.025em;--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity));--tw-shadow:0 1px 2px 0 #0000000d;--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow);border-radius:.125rem;height:38px;padding-left:1rem;padding-right:1rem;font-size:.75rem;font-weight:600;line-height:1rem}@media not all and (min-width:640px){:not(figure)>button{font-size:.85rem}}:not(figure)>button:before{content:var(--tw-content);--tw-bg-opacity:1;background-color:rgb(228 22 92/var(--tw-bg-opacity));border-radius:.125rem}:not(figure)>button:after{--tw-bg-opacity:1;background-color:rgb(228 22 92/var(--tw-bg-opacity));content:var(--tw-content);background-image:none}:not(figure)>button:focus{--tw-ring-offset-shadow:var(--tw-ring-inset)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset)0 0 0 calc(3px + var(--tw-ring-offset-width))var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow,0 0 #0000);--tw-ring-color:rgb(228 22 92/var(--tw-ring-opacity));--tw-ring-opacity:.5}.sr-only{clip:rect(0,0,0,0);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.bottom-0{bottom:0}.left-0{left:0}.right-0{right:0}.top-0{top:0}.top-20{top:5rem}.z-30{z-index:30}.z-50{z-index:50}.float-right{float:right}.m-0{margin:0}.m-4{margin:1rem}.mx-auto{margin-left:auto;margin-right:auto}.-mt-0\.5{margin-top:-.125rem}.-mt-1{margin-top:-.25rem}.-mt-11{margin-top:-2.75rem}.-mt-24{margin-top:-6rem}.mb-1{margin-bottom:.25rem}.mb-12{margin-bottom:3rem}.mb-2{margin-bottom:.5rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-4{margin-left:1rem}.mr-14{margin-right:3.5rem}.mt-0{margin-top:0}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-8{margin-top:2rem}.mt-\[0\.0625rem\]{margin-top:.0625rem}.mt-\[1px\]{margin-top:1px}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.grid{display:grid}.hidden{display:none}.size-\[100px\]{width:100px;height:100px}.h-12{height:3rem}.h-\[300px\]{height:300px}.h-full{height:100%}.w-\[180px\]{width:180px}.w-\[230px\]{width:230px}.w-\[30rem\]{width:30rem}.w-full{width:100%}.min-w-0{min-width:0}.max-w-full{max-width:100%}.shrink-0{flex-shrink:0}.flex-grow,.grow{flex-grow:1}.grow-\[2\]{flex-grow:2}.basis-56{flex-basis:14rem}.cursor-pointer{cursor:pointer}.list-outside{list-style-position:outside}.list-\[square\]{list-style-type:square}.list-none{list-style-type:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-12{gap:3rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-x-6{-moz-column-gap:1.5rem;column-gap:1.5rem}.gap-y-2{row-gap:.5rem}.scroll-smooth{scroll-behavior:smooth}.rounded-full{border-radius:9999px}.rounded-sm{border-radius:.125rem}.border{border-width:1px}.border-l-4{border-left-width:4px}.border-github\/80{border-color:#1f2328cc}.border-linkedin\/80{border-color:#0a66c2cc}.border-neutral-100{--tw-border-opacity:1;border-color:rgb(245 245 245/var(--tw-border-opacity))}.border-primary{--tw-border-opacity:1;border-color:rgb(27 61 157/var(--tw-border-opacity))}.border-rss\/80{border-color:#f26622cc}.border-twitter\/80{border-color:#1da1f2cc}.bg-black{--tw-bg-opacity:1;background-color:rgb(0 0 0/var(--tw-bg-opacity))}.bg-github{--tw-bg-opacity:1;background-color:rgb(31 35 40/var(--tw-bg-opacity))}.bg-linkedin{--tw-bg-opacity:1;background-color:rgb(10 102 194/var(--tw-bg-opacity))}.bg-primary{--tw-bg-opacity:1;background-color:rgb(27 61 157/var(--tw-bg-opacity))}.bg-rss{--tw-bg-opacity:1;background-color:rgb(242 102 34/var(--tw-bg-opacity))}.bg-twitter{--tw-bg-opacity:1;background-color:rgb(29 161 242/var(--tw-bg-opacity))}.bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.bg-gradient-120{background-image:linear-gradient(120deg,var(--tw-gradient-stops))}.from-primary{--tw-gradient-from:#1b3d9d var(--tw-gradient-from-position);--tw-gradient-to:#1b3d9d00 var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.to-secondary{--tw-gradient-to:#e4165c var(--tw-gradient-to-position)}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-6{padding:1.5rem}.px-4{padding-left:1rem;padding-right:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.px-8{padding-left:2rem;padding-right:2rem}.pb-1{padding-bottom:.25rem}.pb-24{padding-bottom:6rem}.pl-3{padding-left:.75rem}.pt-0\.5{padding-top:.125rem}.text-center{text-align:center}.text-2xl{font-size:1.5rem;line-height:2rem}.text-\[14\.5px\]{font-size:14.5px}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.leading-10{line-height:2.5rem}.leading-normal{line-height:1.5}.text-github{--tw-text-opacity:1;color:rgb(31 35 40/var(--tw-text-opacity))}.text-linkedin{--tw-text-opacity:1;color:rgb(10 102 194/var(--tw-text-opacity))}.text-muted{color:#334155bf}.text-neutral-500{--tw-text-opacity:1;color:rgb(115 115 115/var(--tw-text-opacity))}.text-rss{--tw-text-opacity:1;color:rgb(242 102 34/var(--tw-text-opacity))}.text-secondary{--tw-text-opacity:1;color:rgb(228 22 92/var(--tw-text-opacity))}.text-twitter{--tw-text-opacity:1;color:rgb(29 161 242/var(--tw-text-opacity))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.opacity-0{opacity:0}.opacity-40{opacity:.4}.opacity-70{opacity:.7}.opacity-80{opacity:.8}.shadow-2xl{--tw-shadow:0 25px 50px -12px #00000040;--tw-shadow-colored:0 25px 50px -12px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px #0000001a,0 2px 4px -2px #0000001a;--tw-shadow-colored:0 4px 6px -1px var(--tw-shadow-color),0 2px 4px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.transition-opacity{transition-property:opacity;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.transition-transform{transition-property:transform;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.duration-300{transition-duration:.3s}.duration-500{transition-duration:.5s}@media not all and (min-width:640px){.text-xs{font-size:.85rem}.text-sm{font-size:.95rem}}.content-width{margin-left:1.5rem;margin-right:1.5rem}@media (min-width:640px){.content-width{margin-left:3rem;margin-right:3rem}}@media (min-width:768px){.content-width{margin-left:4rem;margin-right:4rem}}@media (min-width:1024px){.content-width{margin-left:4rem;margin-right:4rem}}@media (min-width:1280px){.content-width{margin-inline:max(5.5rem,50% + -640px + 3rem)}}pre.terminal{--circle-color:#738a9480;--pos-x:30px;--space-x:20px;--pos-y:22px;border-radius:.25rem;padding-top:2.5rem;background:radial-gradient(6px at var(--pos-x)var(--pos-y),var(--circle-color)5.5px,#fff0 6px),radial-gradient(6px at calc(var(--pos-x) + var(--space-x))var(--pos-y),var(--circle-color)5.5px,#fff0 6px),radial-gradient(6px at calc(var(--pos-x) + 2*var(--space-x))var(--pos-y),var(--circle-color)5.5px,#fff0 6px),#17222b!important}pre.terminal code .line:before{content:""}pre.terminal code .line.show-prompt:before{content:"$";opacity:.7}h2,h3{position:relative}:is(h2 a:has(.icon-link),h3 a:has(.icon-link)){text-align:center;color:#334155bf;opacity:0;width:2.2rem;height:100%;font-size:.8em;font-weight:300;display:block;position:absolute;left:-2.2rem}h2 a:has(.icon-link):before{content:"#"}h3 a:has(.icon-link):before{content:"#"}:is(h2:hover a:has(.icon-link),h3:hover a:has(.icon-link)){opacity:.5}:is(h2:hover a:has(.icon-link):hover,h3:hover a:has(.icon-link):hover){opacity:.8}h3 a:has(.icon-link){background-position-y:.8rem;background-size:1.3rem}.before\:rounded-sm:before{content:var(--tw-content);border-radius:.125rem}.before\:bg-twitter:before{content:var(--tw-content);--tw-bg-opacity:1;background-color:rgb(29 161 242/var(--tw-bg-opacity))}.after\:bg-github:after{content:var(--tw-content);--tw-bg-opacity:1;background-color:rgb(31 35 40/var(--tw-bg-opacity))}.after\:bg-linkedin:after{content:var(--tw-content);--tw-bg-opacity:1;background-color:rgb(10 102 194/var(--tw-bg-opacity))}.after\:bg-rss:after{content:var(--tw-content);--tw-bg-opacity:1;background-color:rgb(242 102 34/var(--tw-bg-opacity))}.after\:bg-twitter:after{content:var(--tw-content);--tw-bg-opacity:1;background-color:rgb(29 161 242/var(--tw-bg-opacity))}.after\:bg-none:after{content:var(--tw-content);background-image:none}.group:hover .group-hover\:translate-x-1{--tw-translate-x:.25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y))rotate(var(--tw-rotate))skew(var(--tw-skew-x))skewY(var(--tw-skew-y))scaleX(var(--tw-scale-x))scaleY(var(--tw-scale-y))}@media (min-width:640px){.sm\:mt-6{margin-top:1.5rem}.sm\:h-\[400px\]{height:400px}.sm\:p-10{padding:2.5rem}.sm\:pb-16{padding-bottom:4rem}.sm\:text-\[16px\]{font-size:16px}.sm\:text-xl{font-size:1.25rem;line-height:1.75rem}@media not all and (min-width:1024px){.sm\:max-lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:max-lg\:grid-cols-\[3fr\,4fr\]{grid-template-columns:3fr 4fr}.sm\:max-lg\:gap-4{gap:1rem}}@media not all and (min-width:768px){.sm\:max-md\:block{display:block}}}@media (min-width:768px){.md\:-top-\[1\.5rem\]{top:-1.5rem}.md\:float-right{float:right}.md\:-mr-6{margin-right:-1.5rem}.md\:ml-10{margin-left:2.5rem}.md\:ml-8{margin-left:2rem}.md\:mt-0{margin-top:0}.md\:block{display:block}.md\:flex{display:flex}.md\:h-\[3rem\]{height:3rem}.md\:h-\[4\.5rem\]{height:4.5rem}.md\:w-3\/4{width:75%}.md\:items-center{align-items:center}.md\:justify-between{justify-content:space-between}.md\:border-l-2{border-left-width:2px}.md\:pl-10{padding-left:2.5rem}.md\:leading-none{line-height:1}}@media (min-width:1024px){.lg\:w-\[255px\]{width:255px}.lg\:basis-60{flex-basis:15rem}}@media (min-width:1280px){.xl\:-mr-8{margin-right:-2rem}.xl\:basis-64{flex-basis:16rem}.xl\:px-12{padding-left:3rem;padding-right:3rem}}@media (min-width:1450px){.min-\[1450px\]\:-mr-14{margin-right:-3.5rem}.min-\[1450px\]\:size-\[120px\]{width:120px;height:120px}}body{font-family:Inter,ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}
How many times did you try to make git push
for a newly created branch to the remote repository, only to get a strange “no upstream branch” error? Here I will show how to change Git
configuration with a single command to get rid of it for good.
No upstream branch error
When we create a new branch and try to push it with simple git push
command, Git rejects it with a “no upstream branch” error.
git push
fatal: The current branch feature-1 has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin feature-1
This means that Git doesn’t know to which remote repository it should push our branch, and how this branch should be named on that remote repository.
But then it suggests a solution.
Git suspects that we want to push to default remote, called origin
, and name the remote branch exactly the same as a local one.
Traditional solution
So we need to copy or write this longer version of the command, suggested in the error message.
Since then Git will know that the “upstream” branch for our local one is an origin/feature-1
. We can check it with git branch -vv
command.
Upstream will be shown in square brackets and blue font.
# create new branch
git checkout -b feature-1
# push with --set-upstream parameter
git push --set-upstream origin feature-1
# show branches and their upstreams
git branch -vv
But in most workflows, we will always want to have the remote branch named exactly the same as the local one.
So do we really need to repeat ourselves? Even if it’s only one time, when we try to push a new branch, it’s still distractive.
And who likes to get errors like this?
Simplifying Git branch first push
To make push simpler, we set the following configuration with a command.
git config --global push.default current
Alternatively, we can do this by adding lines to ~/.gitconfig
file to do the same.
[push]
default = current
Now, we can create new branch and push it with a little shorter command.
git push -u
-u
is a shorter version of the --set-upstream
, so the flag still stays.
But we don’t need to specify remote and branch names anymore.
The configuration we’ve introduced makes Git set default upstream configuration for the branch when we use -u
flag, with default parameters.
As a result, it will use default remote, origin
, and the same branch name as the local one.
Sadly, there is no option right now to make Git set tracking information by default.
We always have to do it once.
If we push the new branch without the -u
flag, it will work as well.
However, when we try to pull changes from it later, we will get a familiar error.
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull( 1 ) for details.
git pull < remote > < branch >
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/ < branch > feature-2
Thankfully, even if we push branch without setting upstream and later get this error on pull, we can fix it by simply calling git push -u
at any time.
Or by calling git branch
command suggested by the error message.
Summary
Thanks to setting a simple configuration option to Git push command we avoid Git errors.
Now we are able to push newly created branches with a shorter, easier to remember syntax.
This small optimization will make our workflow more pleasant and less distractful.
✖
Before you leave...
Get Serverless Ebook!
Join the newsletter and get my free ebook about
→ serverless best practices, → Infrastructure as Code, → AWS services, and → architecture patterns.
Thank you! Check your email to confirm subscription.
You are already subscribed. Check your spam folder for newsletter emails.
I'm sorry, something went wrong. Please try again later.
One email with a new post every few weeks. Unsubscribe
anytime.
Hi, I'm Maciej 👋
I'm a Software Developer and Architect, member of the AWS Community Builders. I do serverless
AWS, a bit of frontend, and whatever else needs to be done.
More about me
→
Follow me
Recent Posts