August 30, 2020

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 –

#Git

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

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

Related Posts

Uninstall an Existing Instance of MS SQL Server 2017

July 1, 2020

July 1, 2020 5

Uninstall an Existing Instance of MS SQL Server 2017 If you found this video valuable, give it a like. If...

How To Hard Reset Nokia Lumia 630

July 3, 2020

July 3, 2020 20

You phone saved? Get best wallpaper for your phone from Need to hard reset Nokia Lumia 630? Use our easy...

How to check winrar password without programes

July 9, 2020

July 9, 2020 29

How to check and remove winrar password without any program and software, File Download Link To Know How to download...

Reset Your Home Screen App Icon Layout

July 7, 2020

July 7, 2020 30

Retweet: Name: Reset Your Home Screen App Icon Layout Description: So you’ve installed a ton of tweaks and messed up...

The Right Way to Factory Reset a Samsung Phone | Note 8, S8, S8+

July 2, 2020

July 2, 2020 37

If you own a Samsung phone you will probably need to factory reset it at sometime of the life of...

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...

How to Fix Automatic Repair Loop in Windows 10

July 6, 2020

July 6, 2020 29

In this tutorial you will learn different ways to fix Windows 10 startup issues like Windows 10 Automatic Repair Loop,...

Cách mở khóa điện thoại SAMSUNG khi quên mật khẩu | Hard Reset

July 3, 2020

July 3, 2020 46

Cách mở khóa điện thoại SAMSUNG khi quên mật khẩu | Hard Reset ——————————————-CẢNH BÁO———————————————- – Nội dung video này...

Hướng dẫn cài đặt khôi phục restore Iphone 4,5,6,7,8 về cài đặt gốc – Hai Nguyen Channel

July 2, 2020

July 2, 2020 37

Hướng dẫn cài đặt khôi phục restore Iphone (4,5,6) về cài đặt gốc của nhà sản xuất/ giúp máy nhanh...

Epson L130 L220 L310 L360 L365 Ink pad is at the end of its service life error problem solution

July 7, 2020

July 7, 2020 31

IF YOU SHOW ERROR MESSAGE BY ANY PRINTER EPSON L SERIES printer’s ink pad is at the end of its...

Lounch Startup Repair Windows 7 #Start Windows Normally #Blue Screen Starting Windows

June 28, 2020

June 28, 2020 30

Lounch Startup Repair Windows 7 #Start Windows Normally #Blue Screen Starting Windows # – FRESHCOM Channel adalah Channel Youtube yang...

Cấu hình modem cáp quang Viettel F606 chỉ tiết

July 3, 2020

July 3, 2020 10

Các bước cài đặt modem Viettel F606 chi tiết từ khôi phục cài đặt gốc đến đổi tên và mật...

How to Reset or Format cPanel completely by yourself?

June 29, 2020

June 29, 2020 15

Today in this video you will learn how to reset or format cPanel completely. Follow the steps given below to...

Reset va cài đặt chương trình board 1 kim mã vạch

July 5, 2020

July 5, 2020 23

Sewing machine repair channels always bring you the latest videos, Sign Up Channel to update the new videos, guys …...

How To Hard Reset LG G3

June 30, 2020

June 30, 2020 26

You phone saved? Get best wallpaper for your phone from Hard reset LG G3 to solve a lot of your...

Comments
  • 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:
    https://git-scm.com/docs/git-clean

  • 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)====>

    ALL THE COMMANDS ARE RAN IN GIT BASH.

    KEEP IN MINE THAT THE WORD 'ORIGIN' MEANS REMOTE

    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

    branch.

    Local branch => Only available on your local

    machine or your local

    workspace.

    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

    BUT UNTRACKED FILES WILL STAY AS THEY WERE and

    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 *