![]() You now have a Git repository with a couple of files and several commits, which you can see listed with: git log -onelineį4391b2 (HEAD -> master) Added text to second file. Git commit -m "Added text to second file." Git commit -m "Added text to first file."ĭo the same for the second file: echo "Some example text for the second file." > example-file-2.txt Then stage and commit those changes: echo "Some example text for the first file." > example-file-1.txt Make some changes to the first file, adding some content to it. Use the touch command to create some new empty files: touch example-file-1.txtĪdd the files to the Git staging area, then commit the staged changes: git add. Initialize the new Git repository: git init Here, the new directory, git-example is created in the current user’s home directory: mkdir ~/git-exampleįrom here on, you should execute the given commands while working in this directory. If you have not done this yet, you can learn how in our guide How to Install Git and Clone a GitHub Repository.Ĭreate a new directory for your Git repository, and change into that directory. The steps presume you have already installed Git and done basic configuration (e.g. The commit IDs may be different, but the contents of the repository should otherwise be the same. ![]() These next few steps set you up with an example Git repository similar to the one used for the examples in this tutorial. To get the best effect, you can follow along using a similar Git repository. This guide gives example output for the commands it describes. Learn more about Git generally in our guide Git vs SVN: Pros and Cons of Each Version Control System.įor a more general, and thorough, coverage of reverting Git commits, take a look at our guide on How to Undo a Git Commit. It covers methods using both the revert and reset commands, and explains the differences. Git has the ability to revert the last commit, and this tutorial shows you exactly how. You might need that recoverability after an inadvertent commit, or to undo the most recent commit for any reason. It also keeps track of all the committed changes along the way, so things are readily recoverable. ![]() Git utilizes local clones of central repositories to bring more effective collaboration. Git is a widely used Version Control System (VCS) known for its versatility. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |