From the course: Git for Teams

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Common pitfalls: Force push

Common pitfalls: Force push - Git Tutorial

From the course: Git for Teams

Start my 1-month free trial

Common pitfalls: Force push

- [Instructor] In this lesson were going to walk through another pitfall so that you can avoid it and stay within the good graces of your team. So, one of the errors you have to be careful when working with Git is using commands you might not be familiar with. One of the most dangerous commands that you can use is the push command with the force flag. This can cause you to overwrite commits and lose some of your work, and it gets a little bit awkward when you overwrite your team member's work. So let's walk through a demonstration so that you can avoid it. OK, so in this scenario, what's going to happen is user two is going to create a new file called demo2. They're then going to add that file to the stage then commit the file. And then push that file to the central repository that the team shares. OK, now at this point, user one wants to make a change to the demo file. So they enter vim, and they're going to add some changes to the demo file. OK, so those changes are in place, and…

Contents