Thursday, June 30, 2022
  • Home
  • Event
  • Technology
  • Program
  • Education
No Result
View All Result
E-Capitals
No Result
View All Result
Home Program

Switching Unstaged Changes to a New Branch | CSS-Tricks

admin by admin
January 28, 2022
in Program
0
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter

I’m always on the wrong branch. I’m either on master or main working on something that should be on a fix or feature branch. Or I’m on the last branch I was working on and should have cut a new branch. Oh well. It’s never that big of a deal. Basically means switching unstaged changes to a new branch. This is what I normally do:

  • Stash all the changed-but-unstaged files
  • Move back to master
  • Pull master to make sure it’s up to date
  • Cut a new branch from master
  • Move to the new branch
  • Unstash those changed files

Want a bunch of other Git tips? Our “Advanced Git” series has got a ton of them.

Switching unstaged changes to a new branch with the Git CLI it looks like this

Here’s how I generally switch unstaged changes to a new branch in Git:

git status
git stash --include-untracked
git checkout master
git pull
git branch content/sharis
git checkout content/sharis
git stash pop

Yeah I commit jpgs right to git.

Switching unstaged changes to a new branch in Git Tower it looks like this

I think you could theoretically do each of those steps to switch unstaged changed to a new branch, one-by-one, in Git Tower, too, but the shortcut is that you can make the branch and double-click over to it.

Related Posts

Text-overflow: ellipsis considered harmful | CSS-Tricks

How I Chose an Animation Library for My Project | CSS-Tricks

Help Shape the Future of CSS-Tricks! | CSS-Tricks

My Dumbest CSS Mistakes | CSS-Tricks

Sorry, I’m just doing Git Tower but there are lots of other Git GUIs that probably have clever ways of doing this as well.

But there is a new fancy way!

This way of switching unstaged changes to a new branch is new to me anyway, and it was new to Wes when he tweeted this:

TIL about `git switch`, which allows you to move your unstaged changes to a new branch.

Seems fairly new. I used to `git stash`, new branch, and then `git stash apply` pic.twitter.com/6Rd0fCJOcV

— Wes Bos (@wesbos) January 6, 2022

Cool. That’s:

git switch -c new-branch

Documentation for that here.

Next Post

Join TeachThought University's Digital Library Today -

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Popular Posts

Program

Text-overflow: ellipsis considered harmful | CSS-Tricks

by admin
June 30, 2022
0

Eric Eggert: There are a few legitimate use cases for this technique. For example, you might have a table with...

Read more

Text-overflow: ellipsis considered harmful | CSS-Tricks

Glassdoor hires former Convoy chief economist; Kineta adds exec; and more – GeekWire

#CleartheList? How About #FundOurSchools – WeAreTeachers

Former Convoy director leads new Seattle trucking startup that just raised $8M – GeekWire

Best Shoes for Student Teaching, as Recommended by Real Teachers

How To Become a Substitute Teacher

Load More

Popular Posts

Best Winter Olympics Activities for Kids in the Classroom

by admin
January 19, 2022
0

What is Packet Sniffing Attack? – Types and How to Prevent It?

by admin
December 11, 2021
0

Zain Nadella, 1996-2022: Microsoft CEO’s son remembered for love of music, bright smile, profound impact on his dad

by admin
March 1, 2022
0

Copyright © 2021 - e-Capitals.com DESIGNED AND DEVELOPED BY TEAM WORDPRESS BLOGX

No Result
View All Result
  • Home
    • Home 1
    • Home 2
    • Home 3
  • Event
  • Technology
  • Program
  • Education

Copyright © 2021 - e-capitals.com - DESIGNED AND DEVELOPED BY TEAM WORDPRESS BLOGX