rescue Rescued dogs find new purpose hunting giant invasive snails in the Galapagos By www.mnn.com Published On :: Fri, 10 Apr 2015 12:00:00 +0000 Giant African snails have invaded the Galapagos, but two rescued dogs are sniffing them out and helping researchers fix the ecology of the islands. Full Article Animals
rescue Your social media activity can help and hurt animal rescues By www.mnn.com Published On :: Mon, 14 Mar 2016 12:10:00 +0000 When you share a rescue organization's posts or comment on them, it may not always be what's best for the shelter. Full Article Pets
rescue Firefighters rescue small dog from house fire By www.mnn.com Published On :: Fri, 21 Jul 2017 16:37:41 +0000 Bakersfield firefighters pull an unresponsive pup from a fire and use a specialized animal oxygen mask to revive him. Full Article Pets
rescue Download this game to rescue cats in outer space, and save real-life cats at the same time By www.mnn.com Published On :: Tue, 03 Jun 2014 12:47:54 +0000 The student-designed mobile game Galactickitties lets you save space-flying felines and benefit the ASPCA too. Full Article Pets
rescue Crippled rescue dog finds forever home with Clooney family By www.mnn.com Published On :: Thu, 28 Jan 2016 14:32:38 +0000 The troubled life of Nate the terrier gets a Hollywood ending thanks to George and Amal Clooney. Full Article Animals
rescue Tracey and Jon Stewart are expanding their animal rescue farm By www.mnn.com Published On :: Wed, 20 Apr 2016 15:05:53 +0000 Former 'Daily Show' host and family reportedly have purchased a 45-acre farm near their current operation in New Jersey. Full Article Animals
rescue How Bill Nye will rescue us with science By www.mnn.com Published On :: Sun, 12 Feb 2017 17:23:18 +0000 The Science Guy is back, just in time to 'Save the World' with verifiable facts and guest stars like Alton Brown. Full Article Arts & Culture
rescue Introducing Meghan Markle's rescue dogs By www.mnn.com Published On :: Tue, 28 Nov 2017 21:16:49 +0000 Meghan Markle, who just got engaged to Prince Harry and will be joining the royal family, has developed a passion for saving pups in need. Full Article Pets
rescue This rescued bat can't stuff quite enough banana into those ridiculous cheeks By www.mnn.com Published On :: Tue, 05 Dec 2017 21:21:42 +0000 Before she flew back into the wild, Miss Alicia the bat met a fruit and fell in love. Full Article Animals
rescue Miracle puppy rescued from rubble in Bahamas By www.mnn.com Published On :: Mon, 07 Oct 2019 16:13:59 +0000 Trapped, starving dog is rescued weeks after Hurricane Dorian barreled through the Bahamas. Full Article Pets
rescue Rescuers take plastic fork out of sea turtle's nose By www.mnn.com Published On :: Fri, 18 Dec 2015 20:57:10 +0000 The turtle survived, but a video of the ordeal demonstrates why recycling can be a matter of life and death. Full Article Recycling
rescue Rescuers save nearly 100 baby birds after Oakland tree collapses By www.mnn.com Published On :: Thu, 25 Jul 2019 13:30:19 +0000 Rescue workers swooped in and saved nearly 100 baby birds when tree in Oakland split and started to topple. Full Article Animals
rescue Hero rescues sea turtle from plastic debris By www.mnn.com Published On :: Thu, 16 Jun 2016 17:39:27 +0000 Watch as a WWE observer releases beautiful olive ridley sea turtle from entrapment. Full Article Animals
rescue When hikers need help, who pays for rescue? By www.mnn.com Published On :: Wed, 19 Jun 2019 12:52:40 +0000 If you run into trouble in the great outdoors, your rescue could come with a hefty price tag — but it all depends on where you are. Full Article Wilderness & Resources
rescue Kitty rescued in Bangladesh after getting stuck in a window By www.mnn.com Published On :: Thu, 21 Nov 2019 17:55:58 +0000 Video from Dhaka, Bangladesh shows a young man climbing out to rescue a kitty stuck in a window. Full Article Pets
rescue Meet Narwhal, the rescue puppy with a tail on his forehead By www.mnn.com Published On :: Wed, 04 Dec 2019 13:10:38 +0000 Narwhal, the healthy and happy unicorn puppy, has a tail growing out of his forehead. Full Article Pets
rescue Dog gear company plays fairy godmother to thousands of animal rescues By www.mnn.com Published On :: Thu, 12 Dec 2019 13:18:08 +0000 Max and Neo sends donation boxes to thousands of rescue groups every year. Full Article Pets
rescue This blind, deaf puppy was just rescued from the snow by a kind delivery driver By www.mnn.com Published On :: Tue, 17 Dec 2019 19:21:07 +0000 A UPS driver thought he saw something in the snow. Turns out it was a tiny, white puppy that had been abandoned. Full Article Pets
rescue Watch these rescue pups pick out their Christmas presents By www.mnn.com Published On :: Fri, 27 Dec 2019 20:10:10 +0000 A Rehoming Center in Ireland celebrates Christmas with adoptable dogs by allowing them to pick their own present from donated toys. Full Article Pets
rescue Dying rescue dog is a police K-9 for a day By www.mnn.com Published On :: Wed, 22 Jan 2020 19:18:50 +0000 Eddie Spaghetti, a dying rescue dog, gets to suit up and be a police K-9 for a day. Full Article Pets
rescue Rescue dogs find help in unlikely places By www.mnn.com Published On :: Wed, 04 Mar 2020 13:27:48 +0000 Businesses help homeless dogs get adopted through beer cans and pizza boxes. Full Article Pets
rescue Rescued baby pig feels the sun for the first time By www.mnn.com Published On :: Sat, 18 Nov 2017 14:18:08 +0000 Bella the pig lost his siblings and even a eye on a factory farm in Queensland, Australia, before he found a safe home. Full Article Animals
rescue They braved a war-torn region to rescue 47 animals from the 'Zoo of Sorrow' By www.mnn.com Published On :: Thu, 11 Apr 2019 18:53:20 +0000 47 animals were saved after a daring mission to a zoo in the Gaza Strip. Full Article Animals
rescue Orangutan reaches out to 'rescue' man By www.mnn.com Published On :: Mon, 10 Feb 2020 17:21:27 +0000 Orangutan extends hand to 'rescue' man in snake-infested water during safari in Borneo. Full Article Animals
rescue Comical rescue kitties defy gravity in 'Pounce' By www.mnn.com Published On :: Wed, 26 Oct 2016 11:54:48 +0000 Photographer Seth Casteel casts his lens on the priceless expressions of rescue cats and kittens bounding and jumping through the air. Full Article Pets
rescue 1,000 rescued mutts live the life at Costa Rica's 'Land of the Strays' By www.mnn.com Published On :: Fri, 16 Mar 2018 19:13:06 +0000 'The Land of the Strays' is a dog's paradise. Full Article Animals
rescue What To Look For In A Rescue Cat From An Animal Shelter By www.articlegeek.com Published On :: If you have decided to get a new cat for your family, why not choose one from your local cat rescue home or animal shelter? There are so many animals that are in desperate need of a loving home. Full Article
rescue GFA-supported Workers Use Boats for Rescue and Relief Efforts in Flood-Hit Kerala By www.24-7pressrelease.com Published On :: Wed, 22 Aug 2018 07:00:00 GMT Long-term 'desperate need' likely as thousands lose everything, reports ministry leader appealing for more 'helping hands' Full Article
rescue Best-selling Author Gives Away Free Copies of Her New Book 'Rescue Your Retirement' By www.24-7pressrelease.com Published On :: Wed, 23 Oct 2019 07:00:00 GMT Financial Investigator Pamela Yellen Reveals Wealth-Killing Traps of 401(k)s, IRAs and Roth Plans — and How to Avoid Them Full Article
rescue Mutual Rescue™ Launches National Film Festival Program To Benefit U.S. Shelters and Animal Welfare Groups By www.24-7pressrelease.com Published On :: Fri, 28 Sep 2018 07:00:00 GMT Starting in Colorado and Hawaii, Mutual Rescue launched film festivals, now seeks additional partnerships Full Article
rescue Working Dog Rescue Group Launches Online Press Kit By www.24-7pressrelease.com Published On :: Fri, 15 Mar 2019 07:00:00 GMT Mission K9 Rescue saves working dog lives, features efforts in new online press kit Full Article
rescue Mutual Rescue™ Founder Authors Book About How Adopting Animals Transforms Human Lives By www.24-7pressrelease.com Published On :: Tue, 09 Apr 2019 07:00:00 GMT Carol Novello is the author of "Mutual Rescue: How Adopting a Homeless Animal Can Save You, Too" Full Article
rescue CBD Oil Manufacturer Named "Best" for Pets Partners with Working Dog Rescue Group By www.24-7pressrelease.com Published On :: Wed, 01 May 2019 07:00:00 GMT Receptra Naturals Teams Up with Mission K9 Rescue to Make a Difference for Retired Working Dogs Full Article
rescue Mutual Rescue™ Book Released In Paperback Just In Time for Those Looking for a Great Quarantine Read By www.24-7pressrelease.com Published On :: Fri, 20 Mar 2020 07:00:00 GMT "Mutual Rescue: How Adopting a Homeless Animal Can Save You, Too" launches in paperback April 2020 Full Article
rescue RescueHer - Manufacturer of Luxury Rescue Kits, High-End Cosmetic and Personal Items Expand their Retail Business to Walmart.com and Jet.com By www.24-7pressrelease.com Published On :: Mon, 05 Mar 2018 07:00:00 GMT The ultimate rescue kits and products for women. Always prepared for any occasion! Full Article
rescue SBI prepares Rs 20,000 cr bailout plan to rescue Yes Bank By economictimes.indiatimes.com Published On :: 2020-03-09T21:27:59+05:30 SBI prepares Rs 20,000 cr bailout plan to rescue Yes Bank Full Article
rescue Ohio man rescued after falling 60 feet at Grand Canyon By www.nps.gov Published On :: Tue, 28 Apr 2009 20:00:00 EST A 47 year-old Ohio man was rescued after falling 60 feet while hiking in the Grand Canyon yesterday. https://www.nps.gov/grca/learn/news/grand-canyon-rescue.htm Full Article
rescue Woman Rescued After Fall at Grand Canyon National Park By www.nps.gov Published On :: Wed, 03 Jun 2009 20:00:00 EST Late this afternoon, park rangers rescued a 38 year old woman who had fallen approximately 50 feet near a popular view point in Grand Canyon National Park. https://www.nps.gov/grca/learn/news/news-2009-06-04-rescue.htm Full Article
rescue Man Rescued After Fall at Grand Canyon National Park By www.nps.gov Published On :: Sat, 20 Jun 2009 20:00:00 EST Man rescued after fall in Grand Canyon. https://www.nps.gov/grca/learn/news/man-rescued-after-fall-at-grand-canyon-national-park.htm Full Article
rescue Grand Canyon Resident Rescued After Fall By www.nps.gov Published On :: Mon, 06 Jul 2009 20:00:00 EST A resident of Grand Canyon National Park was rescued via short-haul this morning after suffering a fall during a recreational climb of Newton Butte. https://www.nps.gov/grca/learn/news/news-2009-07-07-short-haul.htm Full Article
rescue Stranded Boaters Rescued, their Boat Freed in Grand Canyon By www.nps.gov Published On :: Thu, 25 Feb 2010 19:00:00 EST A private boating party stranded near Crystal Rapid in Grand Canyon National Park was able to continue down the river late Thursday afternoon after being rescued by National Park Service rangers. https://www.nps.gov/grca/learn/news/2010-02-26_rescue.htm Full Article
rescue Man Rescued after Falling over Edge of Grand Canyon By www.nps.gov Published On :: Wed, 04 Aug 2010 20:00:00 EST At approximately 2:45 p.m., the Grand Canyon Regional Communications Center received a report that a man had fallen over the edge near Mather Point on the South Rim of Grand Canyon National Park https://www.nps.gov/grca/learn/news/5aug10-3_news.htm Full Article
rescue Man Who Fled Rangers Rescued from Below Rim in Grand Canyon National Park By www.nps.gov Published On :: Thu, 21 Apr 2011 20:00:00 EST https://www.nps.gov/grca/learn/news/2011-04-22_over-edge.htm Full Article
rescue Rangers Employ Technical Rescue Techniques to Retrieve Body from Below Rim By www.nps.gov Published On :: Thu, 05 May 2011 20:00:00 EST At approximately 10:45 a.m. today, rangers retrieved the body of a young male from below the South Rim of Grand Canyon National Park. https://www.nps.gov/grca/learn/news/2011-05-06_retrieval.htm Full Article
rescue Man Rescued from Below Rim of Grand Canyon National Park By www.nps.gov Published On :: Tue, 26 Jul 2011 12:06:00 EST https://www.nps.gov/grca/learn/news/2011-07-25_fall.htm Full Article
rescue Man Rescued After Fall in Grand Canyon National Park By www.nps.gov Published On :: Tue, 04 Sep 2012 12:02:00 EST https://www.nps.gov/grca/learn/news/2012-09-04_fall.htm Full Article
rescue Lamb rescued by digger after falling 2ft down a drainpipe By www.chroniclelive.co.uk Published On :: Sat, 9 May 2020 11:04:21 +0000 Thankfully the little lamb was unharmed by the ordeal and was reunited with his mum Full Article News
rescue Committed to the wrong branch? -, @{upstream}, and @{-1} to the rescue By feedproxy.google.com Published On :: Thu, 27 Feb 2020 00:00:00 -0500 I get into this situation sometimes. Maybe you do too. I merge feature work into a branch used to collect features, and then continue development but on that branch instead of back on the feature branch git checkout feature # ... bunch of feature commits ... git push git checkout qa-environment git merge --no-ff --no-edit feature git push # deploy qa-environment to the QA remote environment # ... more feature commits ... # oh. I'm not committing in the feature branch like I should be and have to move those commits to the feature branch they belong in and take them out of the throwaway accumulator branch git checkout feature git cherry-pick origin/qa-environment..qa-environment git push git checkout qa-environment git reset --hard origin/qa-environment git merge --no-ff --no-edit feature git checkout feature # ready for more feature commits Maybe you prefer git branch -D qa-environment git checkout qa-environment over git checkout qa-environment git reset --hard origin/qa-environment Either way, that works. But it'd be nicer if we didn't have to type or even remember the branches' names and the remote's name. They are what is keeping this from being a context-independent string of commands you run any time this mistake happens. That's what we're going to solve here.Shorthands for longevityI like to use all possible natively supported shorthands. There are two broad motivations for that.Fingers have a limited number of movements in them. Save as many as possible left late in life.Current research suggests that multitasking has detrimental effects on memory. Development tends to be very heavy on multitasking. Maybe relieving some of the pressure on quick-access short term memory (like knowing all relevant branch names) add up to leave a healthier memory down the line.First up for our scenario: the - shorthand, which refers to the previously checked out branch. There are a few places we can't use it, but it helps a lot: Bash # USING - git checkout feature # hack hack hack git push git checkout qa-environment git merge --no-ff --no-edit - # ???? git push # hack hack hack # whoops git checkout - # now on feature ???? git cherry-pick origin/qa-environment..qa-environment git push git checkout - # now on qa-environment ???? git reset --hard origin/qa-environment git merge --no-ff --no-edit - # ???? git checkout - # ???? # on feature and ready for more feature commits Bash # ORIGINAL git checkout feature # hack hack hack git push git checkout qa-environment git merge --no-ff --no-edit feature git push # hack hack hack # whoops git checkout feature git cherry-pick origin/qa-environment..qa-environment git push git checkout qa-environment git reset --hard origin/qa-environment git merge --no-ff --no-edit feature git checkout feature # ready for more feature commits Switch We cannot use - when cherry-picking a range > git cherry-pick origin/-..- fatal: bad revision 'origin/-..-' > git cherry-pick origin/qa-environment..- fatal: bad revision 'origin/qa-environment..-' and even if we could we'd still have provide the remote's name (here, origin).That shorthand doesn't apply in the later reset --hard command, and we cannot use it in the branch -D && checkout approach either. branch -D does not support the - shorthand and once the branch is deleted checkout can't reach it with -: # assuming that branch-a has an upstream origin/branch-a > git checkout branch-a > git checkout branch-b > git checkout - > git branch -D - error: branch '-' not found. > git branch -D branch-a > git checkout - error: pathspec '-' did not match any file(s) known to git So we have to remember the remote's name (we know it's origin because we are devoting memory space to knowing that this isn't one of those times it's something else), the remote tracking branch's name, the local branch's name, and we're typing those all out. No good! Let's figure out some shorthands.@{-<n>} is hard to say but easy to fall in love withWe can do a little better by using @{-<n>} (you'll also sometimes see it referred to be the older @{-N}). It is a special construct for referring to the nth previously checked out ref. > git checkout branch-a > git checkout branch-b > git rev-parse --abbrev-rev @{-1} # the name of the previously checked out branch branch-a > git checkout branch-c > git rev-parse --abbrev-rev @{-2} # the name of branch checked out before the previously checked out one branch-a Back in our scenario, we're on qa-environment, we switch to feature, and then want to refer to qa-environment. That's @{-1}! So instead of git cherry-pick origin/qa-environment..qa-environment We can do git cherry-pick origin/qa-environment..@{-1} Here's where we are (🎉 marks wins from -, 💥 marks the win from @{-1}) Bash # USING - AND @{-1} git checkout feature # hack hack hack git push git checkout qa-environment git merge --no-ff --no-edit - # ???? git push # hack hack hack # whoops git checkout - # ???? git cherry-pick origin/qa-environment..@{-1} # ???? git push git checkout - # ???? git reset --hard origin/qa-environment git merge --no-ff --no-edit - # ???? git checkout - # ???? # ready for more feature commits Bash # ORIGINAL git checkout feature # hack hack hack git push git checkout qa-environment git merge --no-ff --no-edit feature git push # hack hack hack # whoops git checkout feature git cherry-pick origin/qa-environment..qa-environment git push git checkout qa-environment git reset --hard origin/qa-environment git merge --no-ff --no-edit feature git checkout feature # ready for more feature commits Switch One down, two to go: we're still relying on memory for the remote's name and the remote branch's name and we're still typing both out in full. Can we replace those with generic shorthands?@{-1} is the ref itself, not the ref's name, we can't do > git cherry-pick origin/@{-1}..@{-1} origin/@{-1} fatal: ambiguous argument 'origin/@{-1}': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' because there is no branch origin/@{-1}. For the same reason, @{-1} does not give us a generalized shorthand for the scenario's later git reset --hard origin/qa-environment command.But good news!Do @{u} @{push} @{upstream} or its shorthand @{u} is the remote branch a that would be pulled from if git pull were run. @{push} is the remote branch that would be pushed to if git push was run. > git checkout branch-a Switched to branch 'branch-a' Your branch is ahead of 'origin/branch-a' by 3 commits. (use "git push" to publish your local commits) > git reset --hard origin/branch-a HEAD is now at <the SHA origin/branch-a is at> we can > git checkout branch-a Switched to branch 'branch-a' Your branch is ahead of 'origin/branch-a' by 3 commits. (use "git push" to publish your local commits) > git reset --hard @{u} # <-- So Cool! HEAD is now at <the SHA origin/branch-a is at> Tacking either onto a branch name will give that branch's @{upstream} or @{push}. For example git checkout branch-a@{u} is the branch branch-a pulls from.In the common workflow where a branch pulls from and pushes to the same branch, @{upstream} and @{push} will be the same, leaving @{u} as preferable for its terseness. @{push} shines in triangular workflows where you pull from one remote and push to another (see the external links below).Going back to our scenario, it means short, portable commands with a minimum human memory footprint. (🎉 marks wins from -, 💥 marks the win from @{-1}, 😎 marks the wins from @{u}.) Bash # USING - AND @{-1} AND @{u} git checkout feature # hack hack hack git push git checkout qa-environment git merge --no-ff --no-edit - # ???? git push # hack hack hack # whoops git checkout - # ???? git cherry-pick @{-1}@{u}..@{-1} # ???????? git push git checkout - # ???? git reset --hard @{u} # ???? git merge --no-ff --no-edit - # ???? git checkout - # ???? # ready for more feature commits Bash # ORIGINAL git checkout feature # hack hack hack git push git checkout qa-environment git merge --no-ff --no-edit feature git push # hack hack hack # whoops git checkout feature git cherry-pick origin/qa-environment..qa-environment git push git checkout qa-environment git reset --hard origin/qa-environment git merge --no-ff --no-edit feature git checkout feature # ready for more feature commits Switch Make the things you repeat the easiest to doBecause these commands are generalized, we can run some series of them once, maybe git checkout - && git reset --hard @{u} && git checkout - or git checkout - && git cherry-pick @{-1}@{u}.. @{-1} && git checkout - && git reset --hard @{u} && git checkout - and then those will be in the shell history just waiting to be retrieved and run again the next time, whether with CtrlR incremental search or history substring searching bound to the up arrow or however your interactive shell is configured. Or make it an alias, or even better an abbreviation if your interactive shell supports them. Save the body wear and tear, give memory a break, and level up in Git.And keep goingThe GitHub blog has a good primer on triangular workflows and how they can polish your process of contributing to external projects.The FreeBSD Wiki has a more in-depth article on triangular workflow process (though it doesn't know about @{push} and @{upstream}).The construct @{-<n>} and the suffixes @{push} and @{upstream} are all part of the gitrevisions spec. Direct links to each:@{-<n>}@{push}@{upstream} Full Article Code Front-end Engineering Back-end Engineering
rescue Committed to the wrong branch? -, @{upstream}, and @{-1} to the rescue By feedproxy.google.com Published On :: Thu, 27 Feb 2020 00:00:00 -0500 I get into this situation sometimes. Maybe you do too. I merge feature work into a branch used to collect features, and then continue development but on that branch instead of back on the feature branch git checkout feature # ... bunch of feature commits ... git push git checkout qa-environment git merge --no-ff --no-edit feature git push # deploy qa-environment to the QA remote environment # ... more feature commits ... # oh. I'm not committing in the feature branch like I should be and have to move those commits to the feature branch they belong in and take them out of the throwaway accumulator branch git checkout feature git cherry-pick origin/qa-environment..qa-environment git push git checkout qa-environment git reset --hard origin/qa-environment git merge --no-ff --no-edit feature git checkout feature # ready for more feature commits Maybe you prefer git branch -D qa-environment git checkout qa-environment over git checkout qa-environment git reset --hard origin/qa-environment Either way, that works. But it'd be nicer if we didn't have to type or even remember the branches' names and the remote's name. They are what is keeping this from being a context-independent string of commands you run any time this mistake happens. That's what we're going to solve here.Shorthands for longevityI like to use all possible natively supported shorthands. There are two broad motivations for that.Fingers have a limited number of movements in them. Save as many as possible left late in life.Current research suggests that multitasking has detrimental effects on memory. Development tends to be very heavy on multitasking. Maybe relieving some of the pressure on quick-access short term memory (like knowing all relevant branch names) add up to leave a healthier memory down the line.First up for our scenario: the - shorthand, which refers to the previously checked out branch. There are a few places we can't use it, but it helps a lot: Bash # USING - git checkout feature # hack hack hack git push git checkout qa-environment git merge --no-ff --no-edit - # ???? git push # hack hack hack # whoops git checkout - # now on feature ???? git cherry-pick origin/qa-environment..qa-environment git push git checkout - # now on qa-environment ???? git reset --hard origin/qa-environment git merge --no-ff --no-edit - # ???? git checkout - # ???? # on feature and ready for more feature commits Bash # ORIGINAL git checkout feature # hack hack hack git push git checkout qa-environment git merge --no-ff --no-edit feature git push # hack hack hack # whoops git checkout feature git cherry-pick origin/qa-environment..qa-environment git push git checkout qa-environment git reset --hard origin/qa-environment git merge --no-ff --no-edit feature git checkout feature # ready for more feature commits Switch We cannot use - when cherry-picking a range > git cherry-pick origin/-..- fatal: bad revision 'origin/-..-' > git cherry-pick origin/qa-environment..- fatal: bad revision 'origin/qa-environment..-' and even if we could we'd still have provide the remote's name (here, origin).That shorthand doesn't apply in the later reset --hard command, and we cannot use it in the branch -D && checkout approach either. branch -D does not support the - shorthand and once the branch is deleted checkout can't reach it with -: # assuming that branch-a has an upstream origin/branch-a > git checkout branch-a > git checkout branch-b > git checkout - > git branch -D - error: branch '-' not found. > git branch -D branch-a > git checkout - error: pathspec '-' did not match any file(s) known to git So we have to remember the remote's name (we know it's origin because we are devoting memory space to knowing that this isn't one of those times it's something else), the remote tracking branch's name, the local branch's name, and we're typing those all out. No good! Let's figure out some shorthands.@{-<n>} is hard to say but easy to fall in love withWe can do a little better by using @{-<n>} (you'll also sometimes see it referred to be the older @{-N}). It is a special construct for referring to the nth previously checked out ref. > git checkout branch-a > git checkout branch-b > git rev-parse --abbrev-rev @{-1} # the name of the previously checked out branch branch-a > git checkout branch-c > git rev-parse --abbrev-rev @{-2} # the name of branch checked out before the previously checked out one branch-a Back in our scenario, we're on qa-environment, we switch to feature, and then want to refer to qa-environment. That's @{-1}! So instead of git cherry-pick origin/qa-environment..qa-environment We can do git cherry-pick origin/qa-environment..@{-1} Here's where we are (🎉 marks wins from -, 💥 marks the win from @{-1}) Bash # USING - AND @{-1} git checkout feature # hack hack hack git push git checkout qa-environment git merge --no-ff --no-edit - # ???? git push # hack hack hack # whoops git checkout - # ???? git cherry-pick origin/qa-environment..@{-1} # ???? git push git checkout - # ???? git reset --hard origin/qa-environment git merge --no-ff --no-edit - # ???? git checkout - # ???? # ready for more feature commits Bash # ORIGINAL git checkout feature # hack hack hack git push git checkout qa-environment git merge --no-ff --no-edit feature git push # hack hack hack # whoops git checkout feature git cherry-pick origin/qa-environment..qa-environment git push git checkout qa-environment git reset --hard origin/qa-environment git merge --no-ff --no-edit feature git checkout feature # ready for more feature commits Switch One down, two to go: we're still relying on memory for the remote's name and the remote branch's name and we're still typing both out in full. Can we replace those with generic shorthands?@{-1} is the ref itself, not the ref's name, we can't do > git cherry-pick origin/@{-1}..@{-1} origin/@{-1} fatal: ambiguous argument 'origin/@{-1}': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' because there is no branch origin/@{-1}. For the same reason, @{-1} does not give us a generalized shorthand for the scenario's later git reset --hard origin/qa-environment command.But good news!Do @{u} @{push} @{upstream} or its shorthand @{u} is the remote branch a that would be pulled from if git pull were run. @{push} is the remote branch that would be pushed to if git push was run. > git checkout branch-a Switched to branch 'branch-a' Your branch is ahead of 'origin/branch-a' by 3 commits. (use "git push" to publish your local commits) > git reset --hard origin/branch-a HEAD is now at <the SHA origin/branch-a is at> we can > git checkout branch-a Switched to branch 'branch-a' Your branch is ahead of 'origin/branch-a' by 3 commits. (use "git push" to publish your local commits) > git reset --hard @{u} # <-- So Cool! HEAD is now at <the SHA origin/branch-a is at> Tacking either onto a branch name will give that branch's @{upstream} or @{push}. For example git checkout branch-a@{u} is the branch branch-a pulls from.In the common workflow where a branch pulls from and pushes to the same branch, @{upstream} and @{push} will be the same, leaving @{u} as preferable for its terseness. @{push} shines in triangular workflows where you pull from one remote and push to another (see the external links below).Going back to our scenario, it means short, portable commands with a minimum human memory footprint. (🎉 marks wins from -, 💥 marks the win from @{-1}, 😎 marks the wins from @{u}.) Bash # USING - AND @{-1} AND @{u} git checkout feature # hack hack hack git push git checkout qa-environment git merge --no-ff --no-edit - # ???? git push # hack hack hack # whoops git checkout - # ???? git cherry-pick @{-1}@{u}..@{-1} # ???????? git push git checkout - # ???? git reset --hard @{u} # ???? git merge --no-ff --no-edit - # ???? git checkout - # ???? # ready for more feature commits Bash # ORIGINAL git checkout feature # hack hack hack git push git checkout qa-environment git merge --no-ff --no-edit feature git push # hack hack hack # whoops git checkout feature git cherry-pick origin/qa-environment..qa-environment git push git checkout qa-environment git reset --hard origin/qa-environment git merge --no-ff --no-edit feature git checkout feature # ready for more feature commits Switch Make the things you repeat the easiest to doBecause these commands are generalized, we can run some series of them once, maybe git checkout - && git reset --hard @{u} && git checkout - or git checkout - && git cherry-pick @{-1}@{u}.. @{-1} && git checkout - && git reset --hard @{u} && git checkout - and then those will be in the shell history just waiting to be retrieved and run again the next time, whether with CtrlR incremental search or history substring searching bound to the up arrow or however your interactive shell is configured. Or make it an alias, or even better an abbreviation if your interactive shell supports them. Save the body wear and tear, give memory a break, and level up in Git.And keep goingThe GitHub blog has a good primer on triangular workflows and how they can polish your process of contributing to external projects.The FreeBSD Wiki has a more in-depth article on triangular workflow process (though it doesn't know about @{push} and @{upstream}).The construct @{-<n>} and the suffixes @{push} and @{upstream} are all part of the gitrevisions spec. Direct links to each:@{-<n>}@{push}@{upstream} Full Article Code Front-end Engineering Back-end Engineering
rescue Committed to the wrong branch? -, @{upstream}, and @{-1} to the rescue By feedproxy.google.com Published On :: Thu, 27 Feb 2020 00:00:00 -0500 I get into this situation sometimes. Maybe you do too. I merge feature work into a branch used to collect features, and then continue development but on that branch instead of back on the feature branch git checkout feature # ... bunch of feature commits ... git push git checkout qa-environment git merge --no-ff --no-edit feature git push # deploy qa-environment to the QA remote environment # ... more feature commits ... # oh. I'm not committing in the feature branch like I should be and have to move those commits to the feature branch they belong in and take them out of the throwaway accumulator branch git checkout feature git cherry-pick origin/qa-environment..qa-environment git push git checkout qa-environment git reset --hard origin/qa-environment git merge --no-ff --no-edit feature git checkout feature # ready for more feature commits Maybe you prefer git branch -D qa-environment git checkout qa-environment over git checkout qa-environment git reset --hard origin/qa-environment Either way, that works. But it'd be nicer if we didn't have to type or even remember the branches' names and the remote's name. They are what is keeping this from being a context-independent string of commands you run any time this mistake happens. That's what we're going to solve here.Shorthands for longevityI like to use all possible natively supported shorthands. There are two broad motivations for that.Fingers have a limited number of movements in them. Save as many as possible left late in life.Current research suggests that multitasking has detrimental effects on memory. Development tends to be very heavy on multitasking. Maybe relieving some of the pressure on quick-access short term memory (like knowing all relevant branch names) add up to leave a healthier memory down the line.First up for our scenario: the - shorthand, which refers to the previously checked out branch. There are a few places we can't use it, but it helps a lot: Bash # USING - git checkout feature # hack hack hack git push git checkout qa-environment git merge --no-ff --no-edit - # ???? git push # hack hack hack # whoops git checkout - # now on feature ???? git cherry-pick origin/qa-environment..qa-environment git push git checkout - # now on qa-environment ???? git reset --hard origin/qa-environment git merge --no-ff --no-edit - # ???? git checkout - # ???? # on feature and ready for more feature commits Bash # ORIGINAL git checkout feature # hack hack hack git push git checkout qa-environment git merge --no-ff --no-edit feature git push # hack hack hack # whoops git checkout feature git cherry-pick origin/qa-environment..qa-environment git push git checkout qa-environment git reset --hard origin/qa-environment git merge --no-ff --no-edit feature git checkout feature # ready for more feature commits Switch We cannot use - when cherry-picking a range > git cherry-pick origin/-..- fatal: bad revision 'origin/-..-' > git cherry-pick origin/qa-environment..- fatal: bad revision 'origin/qa-environment..-' and even if we could we'd still have provide the remote's name (here, origin).That shorthand doesn't apply in the later reset --hard command, and we cannot use it in the branch -D && checkout approach either. branch -D does not support the - shorthand and once the branch is deleted checkout can't reach it with -: # assuming that branch-a has an upstream origin/branch-a > git checkout branch-a > git checkout branch-b > git checkout - > git branch -D - error: branch '-' not found. > git branch -D branch-a > git checkout - error: pathspec '-' did not match any file(s) known to git So we have to remember the remote's name (we know it's origin because we are devoting memory space to knowing that this isn't one of those times it's something else), the remote tracking branch's name, the local branch's name, and we're typing those all out. No good! Let's figure out some shorthands.@{-<n>} is hard to say but easy to fall in love withWe can do a little better by using @{-<n>} (you'll also sometimes see it referred to be the older @{-N}). It is a special construct for referring to the nth previously checked out ref. > git checkout branch-a > git checkout branch-b > git rev-parse --abbrev-rev @{-1} # the name of the previously checked out branch branch-a > git checkout branch-c > git rev-parse --abbrev-rev @{-2} # the name of branch checked out before the previously checked out one branch-a Back in our scenario, we're on qa-environment, we switch to feature, and then want to refer to qa-environment. That's @{-1}! So instead of git cherry-pick origin/qa-environment..qa-environment We can do git cherry-pick origin/qa-environment..@{-1} Here's where we are (🎉 marks wins from -, 💥 marks the win from @{-1}) Bash # USING - AND @{-1} git checkout feature # hack hack hack git push git checkout qa-environment git merge --no-ff --no-edit - # ???? git push # hack hack hack # whoops git checkout - # ???? git cherry-pick origin/qa-environment..@{-1} # ???? git push git checkout - # ???? git reset --hard origin/qa-environment git merge --no-ff --no-edit - # ???? git checkout - # ???? # ready for more feature commits Bash # ORIGINAL git checkout feature # hack hack hack git push git checkout qa-environment git merge --no-ff --no-edit feature git push # hack hack hack # whoops git checkout feature git cherry-pick origin/qa-environment..qa-environment git push git checkout qa-environment git reset --hard origin/qa-environment git merge --no-ff --no-edit feature git checkout feature # ready for more feature commits Switch One down, two to go: we're still relying on memory for the remote's name and the remote branch's name and we're still typing both out in full. Can we replace those with generic shorthands?@{-1} is the ref itself, not the ref's name, we can't do > git cherry-pick origin/@{-1}..@{-1} origin/@{-1} fatal: ambiguous argument 'origin/@{-1}': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' because there is no branch origin/@{-1}. For the same reason, @{-1} does not give us a generalized shorthand for the scenario's later git reset --hard origin/qa-environment command.But good news!Do @{u} @{push} @{upstream} or its shorthand @{u} is the remote branch a that would be pulled from if git pull were run. @{push} is the remote branch that would be pushed to if git push was run. > git checkout branch-a Switched to branch 'branch-a' Your branch is ahead of 'origin/branch-a' by 3 commits. (use "git push" to publish your local commits) > git reset --hard origin/branch-a HEAD is now at <the SHA origin/branch-a is at> we can > git checkout branch-a Switched to branch 'branch-a' Your branch is ahead of 'origin/branch-a' by 3 commits. (use "git push" to publish your local commits) > git reset --hard @{u} # <-- So Cool! HEAD is now at <the SHA origin/branch-a is at> Tacking either onto a branch name will give that branch's @{upstream} or @{push}. For example git checkout branch-a@{u} is the branch branch-a pulls from.In the common workflow where a branch pulls from and pushes to the same branch, @{upstream} and @{push} will be the same, leaving @{u} as preferable for its terseness. @{push} shines in triangular workflows where you pull from one remote and push to another (see the external links below).Going back to our scenario, it means short, portable commands with a minimum human memory footprint. (🎉 marks wins from -, 💥 marks the win from @{-1}, 😎 marks the wins from @{u}.) Bash # USING - AND @{-1} AND @{u} git checkout feature # hack hack hack git push git checkout qa-environment git merge --no-ff --no-edit - # ???? git push # hack hack hack # whoops git checkout - # ???? git cherry-pick @{-1}@{u}..@{-1} # ???????? git push git checkout - # ???? git reset --hard @{u} # ???? git merge --no-ff --no-edit - # ???? git checkout - # ???? # ready for more feature commits Bash # ORIGINAL git checkout feature # hack hack hack git push git checkout qa-environment git merge --no-ff --no-edit feature git push # hack hack hack # whoops git checkout feature git cherry-pick origin/qa-environment..qa-environment git push git checkout qa-environment git reset --hard origin/qa-environment git merge --no-ff --no-edit feature git checkout feature # ready for more feature commits Switch Make the things you repeat the easiest to doBecause these commands are generalized, we can run some series of them once, maybe git checkout - && git reset --hard @{u} && git checkout - or git checkout - && git cherry-pick @{-1}@{u}.. @{-1} && git checkout - && git reset --hard @{u} && git checkout - and then those will be in the shell history just waiting to be retrieved and run again the next time, whether with CtrlR incremental search or history substring searching bound to the up arrow or however your interactive shell is configured. Or make it an alias, or even better an abbreviation if your interactive shell supports them. Save the body wear and tear, give memory a break, and level up in Git.And keep goingThe GitHub blog has a good primer on triangular workflows and how they can polish your process of contributing to external projects.The FreeBSD Wiki has a more in-depth article on triangular workflow process (though it doesn't know about @{push} and @{upstream}).The construct @{-<n>} and the suffixes @{push} and @{upstream} are all part of the gitrevisions spec. Direct links to each:@{-<n>}@{push}@{upstream} Full Article Code Front-end Engineering Back-end Engineering