this post was submitted on 11 Aug 2023
302 points (98.7% liked)

Programming Humor

2804 readers
1 users here now

Related Communities [email protected] [email protected] [email protected] [email protected]

Other Programming Communities [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]

founded 2 years ago
MODERATORS
302
submitted 2 years ago* (last edited 2 years ago) by 2e8a9d6bb6935a54 to c/programminghumor
 

Want to make a branch ?

git checkout

Want to make switch branches ?

git checkout

Want to get a specific file version ?

git checkout

Want to get remove changes to one file ?

Believe it or not, also git checkout

all 16 comments
sorted by: hot top controversial new old
[–] [email protected] 22 points 2 years ago (2 children)

I confess, I use switch now

[–] Vikthor 14 points 2 years ago

And there is also git restore now.

[–] tdawg 14 points 2 years ago (1 children)

Fun fact! If you have to quickly swap between two different branches you should try:

git checkout -

It will swap to the previous branch you were on. Have fun!

[–] [email protected] 5 points 2 years ago

git switch - also works for this

[–] [email protected] 8 points 2 years ago

We have the best flows in the world... Because of git checkout

[–] bappity 5 points 2 years ago (1 children)

only just found out how cherry picking works I love it

[–] richard_wagner 2 points 2 years ago (1 children)

Nice, would you explain cherry picking to me, a dummy?

[–] bappity 4 points 2 years ago* (last edited 2 years ago) (1 children)

You can copy a commit that was pushed in branch 1 and paste it to branch 2

[–] richard_wagner 1 points 2 years ago (1 children)

Thanks. I wonder what effect that has on the git history of branch 2?

For some reason I thought cherry picking might be the ability to take any file from any commit on any branch and copying it to the current branch.

[–] bappity 2 points 2 years ago (1 children)

the pasted commit will be at the top of the history for branch 2

[–] BradleyUffner 1 points 2 years ago (1 children)

That seems like it would cause chaos if those branches were ever merged.

[–] [email protected] 6 points 2 years ago

Git's smart enough to realize it's the same commit and skip it.

Common workflow use of cherry-pick:

  1. Say you have a master branch and a release branch
  2. You have a bug in production (off your release branch)
  3. You have other changes in master that are not ready for release
  4. You make a commit to fix the bug and merge to master, run CI and verify it's fixed
  5. Cherry pick the change to the release branch and release as normal
  6. Merge with master before next release to make sure you can cut a new release

All this works without issue.

[–] burning_beard 1 points 2 months ago

This checks out!

[–] rain_worl 0 points 5 months ago

alias git to git checkout