January 16, 2021

Git Tutorial: Fixing Common Mistakes and Undoing Bad Commits

In this video we will look at some common mistakes in Git and how we can fix these mistakes. Specifically we will cover how to discard changes since your last commit, amending commits, cherry-picking hashes, resetting to a specific commit, and reverting to a specific commit.

✅ Support My Channel Through Patreon:

✅ Become a Channel Member:

✅ One-Time Contribution Through PayPal:

✅ Cryptocurrency Donations:
Bitcoin Wallet – 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet – 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet – MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey’s Public Amazon Wishlist

✅ Equipment I Use and Books I Recommend:

▶️ You Can Find Me On:
My Website –
My Second Channel –
Facebook –
Twitter –
Instagram –


Nguồn: https://belahanajima.com/

Xem thêm bài viết khác: https://belahanajima.com/cong-nghe/

Related Posts

Removewat 2.2.6 for You to Activate Your Windows

July 6, 2020

July 6, 2020 14

Removewat 2.2.6 for You to Activate Your Windows : To download it you visit here : Note: Removewat can has...

HARD RESET NOKIA LUMIA 520 (625, 630, 720, 730, 830, 1020 / Restaurar / Resetear)

July 3, 2020

July 3, 2020 33

Explicación detallada de como hacer el hard reset de un Nokia Lumia 520 y otros. ================================= NOTA IMPORTANTE¡¡ 👉(OBSEQUIO al...

Cách Đổi Mật Khẩu WiFi Mạng VNPT Mới Nhất

July 6, 2020

July 6, 2020 21

Tiết lộ cách duy nhất cách đổi mật khẩu wifi nhà mạng VNPT ( Modem 040 , 020 ) không...

Khôi phục cài đặt gốc, factory reset iPhone | EZ TECH CLASS

July 4, 2020

July 4, 2020 2

Trong video ngày hôm nay EZ TECH CLASS chia sẻ cùng các bạn cách khôi phục cài đặt gốc (factory...

Cách sử dụng Windows Repair để sửa lỗi tự động Windows 7 (How to Repair Windows 7)

July 1, 2020

July 1, 2020 1

✍ Hướng dẫn cách sử dụng Windows Repair để sửa lỗi tự động cho Windows 7 (How to Repair Windows...

re:plus × Yusuke Shima / Glittering sea

July 7, 2020

July 7, 2020 22

from album “Prayer” Glittering sea written by re:plus Produced by re:plus × Yusuke Shima re:plus – Keyboard,guitar,bass,beat,program, mixing, mastering Yusuke...

Hướng dẫn cách RESET lại win 10, Recovery khôi phục cài đặt gốc win 10

July 3, 2020

July 3, 2020 30

Cách reset win 10 là chúng ta khôi cài đặt gốc win 10 trở về trạng thái ban đầu như...

Reset máy in Brother HL 2321D 2361DN L2340DW Replace Toner không cần tháo máy

July 5, 2020

July 5, 2020 9

Máy in Brother sau khi sử dụng một thời gian, Trên máy sẽ báo đèn mực hoặc trên màn hình...

[Thủ thuật excel ] Bài 33 – Cách tìm kiếm và thay thế trong excel (FInd and replace)

July 6, 2020

July 6, 2020 2

► Xin chào các bạn. Đây là kênh hướng dẫn sử dụng Excel cả Kiên Trần ► Mình bắt đầu...

Forgot Password – How to Hard Reset Huawei P8 or ANY Huawei Smartphone

July 4, 2020

July 4, 2020 43

A tutorial about how to hard reset any Huawei P8 or any Huawei smartphone running on EMUI like Ascend Mate...

Benerin Komputer Reset Jumper Bios / Cmos #1

July 4, 2020

July 4, 2020 43

komputer ini gak bisa masuk ke windows hanya ada kedip kedip garis strip di kiri atas layar,saya coba benerin dengan...

Cách khắc phục lỗi không reset được win 10

July 8, 2020

July 8, 2020 15

Hướng dẫn mọi người một số cách khắc phục lỗi không reset được win 10, trong một số trường hợp...

How To Erase and Reset a Mac back to factory default

July 5, 2020

July 5, 2020 31

I show you how to erase and reset a Mac back to factory settings in my step-by-step guide. Make sure...

Cách kích hoạt tính năng repair your computer trên win 7,8,10

June 27, 2020

June 27, 2020 40

Cách kích hoạt tính năng repair your computer trên win 7,8,10 Đăng ký kênh của mình tại đây: Facebook của...

123thue.vn Hướng dẫn sử dụng Máy Giặt Samsung WA10J5710SGSV Part 2

July 3, 2020

July 3, 2020 28

#Sửa máy giặt Quá chán nản với việc máy giặt bị hỏng đi hỏng lại, gọi thợ đến thì không...

  • I made a slight mistake in the video. The -f option on git clean is for "force" and not for "files". The documentation can be found here for more info:

  • To get an overview over the complete git history type "git log –all –decorate –oneline –all". You can also assign an alias, so you don't have to write the previous command out everytime. alias graph="git log -all –decorate –oneline –all". Then you can just type graph

  • Nice Video. Thanks.

    Our AWS S3 with GitLab Integration Video https://youtu.be/acKflkrDUYE

  • This is really some very very important content. Thank you. You just got one more subscriber 🙂

  • Why have you pushed feature branch to remote, git push -u origin FeatureBranch. At the end you are eventually deleting that branch, you merged feature branch with master and then pushed master to remote, git push origin master. Why do we have to unnecessarily create a branch in remote and then end up deleting it in the end

  • Do you have a recipe for a scenario where you need to return to an oldish feature branch – you no longer remember what changes you had introduced, so you need a quick diff between the current head and the commit that started the branch? What would be the sneakiest way to find the branch origin SHA?

  • Great vid! When it comes to git reset there is also a "keep" option but I have never had a clear situation to see its benefits.

  • I love the way you teach. It's very easy to understand and apply everything, I do recommend your lectures to everyone cause you are super cool. Thanks man

  • You are awesome. your teaching skills are extraordinary In 21 minutes you just cleared everything that I need to understand to get rid of all those confusions that often happened to me.
    Thank you so much <3

  • great tutorials on advanced concepts… can you also tell how to combine all commit messages into one commit message in git?

  • Just curious: Why can't we use
    git checkout <branch-to-reset-pushed-commits>
    git reset –soft HEAD~(number of commits to be back)
    git commit -A <all what needed to be>
    git push origin <branch> –force
    instead of "revert"ing each of all commits?
    In that way, we could save one commit being extra added to the branch and hence clean.

  • There's GOT to be a way to develop a gui for this as, looking at all this mess, I feel like I'm back to working in DOS, like??? Nah… I'll develop a gui and become as rich as Gates did with his Windoze, mwahahahaha 😈

    (No mind me: cabin fever with this ugh quarantine. Stay safe and thanks again!)

  • 1:42 – Revert back the code that was written
    3:36 – Updating the commit message alone (amend)
    5:50 – Accidentally left off a file that we wanted to commit
    7:38 – Move the commits to a different branch (cherry-pick)
    10:26 – 3 different types of reset
    13:38 – Getting rid of untracked files (git clean)
    15:01 – Retrieve critical files that were lost, and you want them back (git reflog)
    18:10 – Backing out changes, when other people have already checked out your changes (git revert)

  • how do you get your terminal to show current branch? and color code other info ? is that possible in VSCODE?

  • clear screen —————————————> clear

    Check git version ———————————-> git –version

    Add name to global variables ———————–> git config –global user.name "NAME"

    Add name to global variables ———————–> git config –global user.email "EMAIL"

    Check the configurations/ variables —————-> git config –list

    Main git commands (Handling/staging/committing)====>



    REPOSITORY (name)

    1 : go to the working directory

    list files in the directory ——————–> ls -la

    2 : Initialise repository (new) ——————–> git init (Should create a .git file in the directory

    stop tracking directory ————————> rm -rf .git (Make sure to be in the directory)

    3 : check untracked/ tracking files —————-> git status (red = untracked , green = tracked)

    : ignore files that should not be —————-> touch .gitignore (Make sure to be in the directory)

    committed/ staged (Don't put

    .gitignore to the list)

    4 : Check difference ——————————-> git diff

    5 : Track/commit file —————————–> git add -file name (stage a specific file) git add -A (stage all files)

    6 : Remove a file from staging area —————> git reset -file name (un-stage a specific file)

    git reset (un-stage all files)

    7 : Commit all files those are in ——————> git commit -m "-Commit name/message-" (with a message)

    the staging area (git status)

    : (If you run git status now, ——————–> "On branch master nothing to commit, working * directory/tree clean"

    you should see something like this)

    8 : Check the committs —————————–> git log

    9 : Clone and use a repository ——————–> git clone –repository url- -where to clone- (Clone from website)

    10 : Declare the origin for the git repository ——> git remote add origin "–repository url–" (Link must end with a .git)

    11 : Fetch/Get data/files from the repository ——> git pull origin –branch name-

    ===> What is a branch?

    |A branch is a memory of changes that have |

    |been made while the the branch is selected |

    |in the prompt or anywhere else. |

    12 : Make a new branch —————————-> git branch –branch name-

    : There are two typed of branches, one is Local

    branch, the other one is remote tracking


    Local branch => Only available on your local

    machine or your local


    Remote-tracking branch => The branch which

    connects your local

    repository to your

    central repository.

    13 : Delete a local branch ————————> git branch -d –branch name which you want to delete-

    : Delete a remote branch ———————–> git push origin –delete –branch you wanna delete-

    : see all the branches ————————–> git branch -a

    14 : Move to a branch —————————–> git checkout –The branch which you want to go to-

    : A branch is a memory of changes while the

    branch is selected in the prompt.

    15 : Push —————————————–> git push -u origin –from which branch- (This command associates local branch to remote branch)

    16 : Merge a branch to the master branch (or any) –> git merge –branch from which you want to merge into–(Make sure you're in the branch you want to move the changes to such as master)

    17 : See which branches have merged into the ——-> git branch –merged

    branch you're currently on.

    18 : Make the branch a remote repository (Add it –> git push origin –local branch-

    into origin) or watchable by the main website

    19 : Change the commit message of the last commit –> git commit ammend -m "–your updated message–" (The git history/ 40-digit code that you submit in a commit will be diff)

    you did without doing another one.

    20 : How to duplicate a commit from one branch to —–> Go to the branch you wanna copy from

    another if you've committed in a wrong 1: git log to copy the commit code because you'll be needing it

    branch. 2: After you copied the commit code,

    Go to the branch you wanna copy it to

    3: git cherry-pick -commit code/history code/40-digit code-

    21 : How to reset

    22 : Delete commits and git log history ————> 1: Copy commit code

    2: git reset -soft –paste commit code- (soft) (It will not reset the staging area hence we won't loose any work we've done)

    : git reset -paste commit code- (mixed) (It will reset the staging area hence we will loose the work done)

    : git reset -hard –paste commit code- (hard) (It will get rid of EVERYTHING including the staging area THAT IS TRACKED


    the work done)

    23 : How to go back to how things were before ——> 1: git status (The file you modified will be red)

    modification. 2: git diff (You'll see the difference before the last commit on that file)

    3: git checkout -file that you want to revert changes-

    4: git status (You will see that the file is not modified)

    5: git diff (You'll not see any difference)

    Hence, the file has reverted to its last version.

    24 : If you wanted something to get committed ——> 1: Create the file you wanna send to the last commit (Ignore this if the file has already been created)

    in the last commit, do this. 2: Put that in the staging are (The file)

    3: git commit –amend

    Now that a file has probably popped up on your screen, you can edit!

    4: git log –stat (To see the files and changes committed on the log)

  • Nicely covered all git mistakes that people generally do. Thank you very much for making this video.

  • Thanks for informative explanations.

    i have problem that i couldn't find out it.

    i have created a project by root in my UNIX system. then i make a lot of change on that. using git i give accessibility to a non root user "for example Alex" to pull and make his change on the project. but when he wanna write the change, permission denied massage is appeared and he can not write his change on the file. i checked the file permission and i saw the permission of all file and folder in project directory and sub directories change to "rw-r–x–". i wanna keep project file and folder permission on "chmod 666" and prevent change it through deployment by git. what should i do?

Leave a Reply

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