Git Tutorial: How to Undo Git Commits, Rename a Git Branch and Checkout a Previous Commit

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024
  • Web Dev Roadmap for Beginners (Free!): bit.ly/DaveGra...
    Undoing git mistakes can be difficult if you don't know how. This video steps through examples of how you can undo all types of actions in git as well as explaining git branches and merges. Full outline and timestamps below!
    🕓 Outline with timestamps:
    (0:04) Recap Quick Start
    (1:20) git restore [filename] (undo changes)
    (2:18) git restore --staged [filename] (undo staged files)
    (3:09) git log (show log with details)
    (3:45) git log --oneline (shows simplified log)
    (4:35) git commit -v --amend (change last commit's message)
    (6:35) git branch [newBranchName] (creates new branch)
    (7:50) git branch --list (lists all branches)
    (8:05) git checkout [branchName] (switch to this branch)
    (8:10) working with more than one branch
    (12:25) git branch -m [oldBranchName] [newBranchName] (renames branch)
    (14:10) git checkout -b [newBranchName] (creates new branch and switches to it)
    (15:00) git branch -D [branchName] (deletes branch permanently)
    (16:00) git merge [branchName] (merges named branch into branch you are on)
    (17:10) Understanding and handling git merge conflicts
    (22:30) git checkout [commitNumber] (go back to a specific commit number)
    (27:00) git revert [commitNumber] (revert code to a specific commit number by creating new commit)
    (29:30) git reset [commitNumber] (reset code to a specific commit number and unstage the code that came after that commit)
    (31:45) git reset [commitNumber] --hard (reset code to a specific commit and permanently delete the code that came after the commit)
    📺 More Beginner Dev Videos:
    freeCodeCamp: • Learn JavaScript - Ful...
    Traversy Media: • JavaScript Crash Cours...
    The Net Ninja: • Modern JavaScript Tuto...
    ✅ Follow Me:
    Twitter: / yesdavidgray
    Reddit: / daveoneleven
    Medium: / davegray_86804
    #git #commit #tutorial

Комментарии • 17

  • @vasilvasilev6225
    @vasilvasilev6225 2 года назад +1

    Very useful hints, thanks!

  • @ScriptedSep
    @ScriptedSep Год назад +1

    wow, this is amazing! thank you

  • @oshadhaedirisinghe1455
    @oshadhaedirisinghe1455 Месяц назад

    Thank you

  • @elinordeniz
    @elinordeniz Год назад

    the best git tutorial! Thanks

  • @1conscience0dimension
    @1conscience0dimension Год назад

    so you can do a modification on the main branch and then decide to commit it in a different branch. that's why the file was still there in your first example. Because maybe it can be done from the main branch first. I guess

  • @MrBrady95
    @MrBrady95 7 месяцев назад

    Good one, thanks!

  • @MrBrady95
    @MrBrady95 7 месяцев назад

    When using Git and Github within VS Code, it's a convenient feature but I find it confusing to use. For one thing, if you forget to put a message in your commit, a sort of blue line progress indicator comes up and never goes away. It seems to go into an endless loop that I can't get out of unless I restart VS Code. I've run into this issue a number of times as it's easy to forget this step. So, it would be a convenient feature if I could get it to work.

    • @TheLastPhoen1x
      @TheLastPhoen1x Месяц назад

      It attempts to open a text editor (notepad prob) for you to type the message.

  • @shineLouisShine
    @shineLouisShine Год назад

    Thank you very much indeed :)

  • @khueo2032
    @khueo2032 2 года назад

    awesome ,thank u

  • @KamrulIslam-wj1ky
    @KamrulIslam-wj1ky Год назад

    Is there any plan to make full git workflow tutorial?