Git cherry pick tutorial. How to use git cherry-pick.

00:04:24
https://www.youtube.com/watch?v=wIY824wWpu4

Resumen

TLDRThe video provides a guide on how to cherry-pick in Git, a useful feature that allows developers to selectively apply specific commits from one branch to another. Viewers learn how to identify and apply chosen commits, as well as how to make modifications before finalizing the commit. The tutorial highlights the simplicity and effectiveness of cherry-picking, making it a valuable skill for front-end developers and those working with Git.

Para llevar

  • 🍒 Cherry-picking allows selective commit application.
  • 🔍 Use commit IDs to cherry-pick specific changes.
  • ➡️ New commits created have unique IDs in your branch.
  • ✍️ You can cherry-pick multiple commits at once.
  • 🚫 Use '-n' to cherry-pick without immediate commit.
  • 🛠️ Modify changes before finalizing the commit.
  • 💻 Great for bringing in bug fixes without merging full branches.

Cronología

  • 00:00:00 - 00:04:24

    In this video, the presenter introduces Git cherry-picking, a feature that allows users to bring specific changes from one commit into their current branch without merging the entire branch. The tutorial outlines the scenario where a developer needs to import a bug fix from another branch and explains how to identify the commit ID in VS Code. After switching back to their own branch, users can execute the git cherry-pick command to create a new commit with the changes. It is emphasized that cherry-picking creates a new commit rather than just applying the changes directly, making it crucial to understand its function in version control.

Mapa mental

Vídeo de preguntas y respuestas

  • What is cherry-picking in Git?

    Cherry-picking in Git allows you to select specific commits from one branch and apply them to another branch.

  • When should I use cherry-pick?

    You should use cherry-pick when you want to apply specific changes from another branch without merging the entire branch.

  • Can I cherry-pick multiple commits?

    Yes, you can cherry-pick multiple commits by specifying them in your command.

  • What happens to the commit ID when I cherry-pick?

    A new commit is created in your branch with a new ID, reflecting the changes applied.

  • How can I cherry-pick without committing right away?

    Use the command with '-n' to stage changes without creating a commit immediately.

Ver más resúmenes de vídeos

Obtén acceso instantáneo a resúmenes gratuitos de vídeos de YouTube gracias a la IA.
Subtítulos
en
Desplazamiento automático:
  • 00:00:00
    hi there it's better here again the guy
  • 00:00:02
    who ate some arrows but loves front-end
  • 00:00:03
    development in today's video you will
  • 00:00:06
    learn how to cherry-pick
  • 00:00:08
    in a git so if you want to pick some
  • 00:00:10
    cherries keep watching
  • 00:00:15
    now let's have a look at git cherry-pick
  • 00:00:17
    when to use it and what it does it
  • 00:00:21
    brings the changes from a specific
  • 00:00:23
    comment so you can look at another
  • 00:00:25
    branches let's say someone fixed a bug
  • 00:00:27
    that you have in your branch and you
  • 00:00:30
    want to bring in just at one commit and
  • 00:00:32
    not the whole branch that's where you
  • 00:00:34
    would use cherry picking you can choose
  • 00:00:37
    one commit or multiple comments if you
  • 00:00:39
    want to and they will be brought into
  • 00:00:42
    your branch this is what we will have in
  • 00:00:44
    vs code when we switch to the code we'll
  • 00:00:47
    have two branches my branch and his
  • 00:00:48
    branch and three comments on my branch
  • 00:00:51
    and two commits on his branch and we've
  • 00:00:54
    decided to bring in these double a
  • 00:00:59
    commit into our branch okay so how would
  • 00:01:01
    we do it we could use git merge or
  • 00:01:04
    rebase and bring both changes but that's
  • 00:01:08
    not what we want we only want to bring
  • 00:01:10
    the one change okay so we only want to
  • 00:01:13
    bring this one over here and for that we
  • 00:01:17
    will use the git cherry-picking and now
  • 00:01:21
    let's switch to vs code and see it in
  • 00:01:23
    action
  • 00:01:28
    envious code will switch to his branch
  • 00:01:30
    and we'll find out the ID of the commie
  • 00:01:33
    that we want to bring in so kid check
  • 00:01:35
    out - will switch to the previous branch
  • 00:01:38
    we had checked out and now we can have a
  • 00:01:41
    look at a good look and find out the ID
  • 00:01:44
    of the committee okay so this one is the
  • 00:01:46
    one we want to bring in to my branch
  • 00:01:48
    again git checkout - switches back to my
  • 00:01:53
    branch and now we can cherry-pick
  • 00:01:59
    and put
  • 00:02:01
    after that when we execute this we will
  • 00:02:04
    create a new comment on our branch that
  • 00:02:07
    will have the changes ok so we've got
  • 00:02:09
    the changes over here that's the double
  • 00:02:11
    a commit and if we look at the git log
  • 00:02:13
    we'll see that we have a new commit with
  • 00:02:16
    no ID on our brain so it's a similar to
  • 00:02:20
    rebasing you creating new commits so
  • 00:02:23
    just make sure you understand that when
  • 00:02:24
    you bring the change into your branch it
  • 00:02:27
    will apply the same change but create a
  • 00:02:30
    new commit ok so that's how it works
  • 00:02:32
    it's pretty simple and you could also
  • 00:02:34
    choose multiple comments instead of just
  • 00:02:37
    one and you would include them over here
  • 00:02:40
    ok so by that it will create multiple
  • 00:02:43
    commits for each of them that you are
  • 00:02:46
    bringing in
  • 00:02:50
    now what if we wanted to bring the
  • 00:02:52
    changes in but don't commit it straight
  • 00:02:54
    away what if we wanted to maybe add a
  • 00:02:57
    couple other changes before we made the
  • 00:02:59
    initial commit and for that we can also
  • 00:03:02
    use git cherry-pick specify the commit
  • 00:03:06
    we want to merge in and then a hyphen n
  • 00:03:09
    which stands for no commit will bring
  • 00:03:12
    the changes will stage them in our
  • 00:03:14
    working directory but will not create
  • 00:03:17
    the commit straightaway okay so let's do
  • 00:03:19
    this we see the change coming in and
  • 00:03:22
    then we see the stages we see the file
  • 00:03:25
    staged instead of being straightaway
  • 00:03:27
    committed okay so this lets us bring the
  • 00:03:29
    change modify it add to it create a new
  • 00:03:32
    commit message and then merge it okay so
  • 00:03:36
    that's how you bring the changes let's
  • 00:03:38
    how you cherry-pick without committing
  • 00:03:40
    and now we can simply commit it with our
  • 00:03:43
    custom message and we are done ok as you
  • 00:03:46
    can see cherry-picking is quite
  • 00:03:48
    straightforward lets you bring in
  • 00:03:50
    specific changes from specific comments
  • 00:03:53
    instead of bringing the whole branch in
  • 00:03:56
    I hope it was useful and you learned
  • 00:03:59
    something new about cherry picking in Ag
  • 00:04:01
    it and if you did enjoy this kit
  • 00:04:04
    tutorial don't forget to smash to like
  • 00:04:06
    subscribe to the channel so you don't
  • 00:04:08
    miss all the other cool tutorials and
  • 00:04:11
    let me know in the comments what else
  • 00:04:14
    related to giddy you would like to see
  • 00:04:16
    covered next until next time happy
  • 00:04:19
    coding
  • 00:04:19
    bye
  • 00:04:21
    [Music]
Etiquetas
  • Git
  • Cherry-pick
  • Version control
  • Commits
  • Branches
  • Git tutorial
  • Front-end development
  • Coding
  • Software development
  • VS Code