You may run into errors and you might want to go back to your default branch/main. While working as a programmer, it’s inevitable to stage all your project files, line of codes and folders before you commit them. It is in the directory where you will access all your files and folders for the current project.Ī repository stores all the commits that you perform during coding while maintaining both the local copy and remote copy. How does git operate to store repositories, working directories and its indexes?Ī working directory is where your source code will be kept while working and the relevant repo.
$ git clone įor you to understand how to work best with the git reset function, it is important that you comprehend how git stores changes in its working environment. Do not worry about interfering with other developers' work during the implementation as git always creates a local copy for you from the master copy. It is vital when starting a project or collaborating with others remotely to clone it to your local workstation.
I’m running my local workstation on windows 10 pro and will first clone the git_test local repo using the git clone syntax to my computer. To understand the basics, I have set up a project git_test in my gitlab account to illustrate this tutorial. We must set up an environment in which we are going to work. Let us do first things first before learning how to use the git reset. Our focus for this tutorial is an in-depth exploration of how git reset works, scenarios for git reset such as git reset file, git reset origin, and git reset master. Such errors may include committing to a wrong branch, writing an inappropriate commit, or even losing some codes. It’s likely that you will commit errors in codes as a developer and this is where git reset command will be of help. That does not only apply to amateur developers but also the advanced developers. However, you must understand most of its operations to benefit while using it including the git reset command which is our topic of focus in this tutorial. Git is a resourceful platform to work with especially when collaborating with other software developers. Understanding the basic difference between git reset hard vs soft vs mixed.Example 3: git reset -hard Method-2: git reset -mixed.