20 min
- Initialize a new directory in your workspace
cdinto~/code/wdiandmkdira new folder calledgit_practicecdintogit_practice- Run
git initto initialize a new Git repository
- Create 3 new files
- Run
touch file1.txt file2.txt file3.txt
- Check the status of your Git repository
- Run
git status
Note that the three files you've added are marked as untracked because you haven't added them to Git yet. Git's not sure what you want to do with them, so it's basically ignoring them for now.
- Start tracking these files by adding them to Git
- Use
git add .to stage all the files in the current directory that have been modified. In this case, it's all of them. - Check the status of your git repository now by using
git status
Note that the files are now marked as new file
- Commit your changes
- Use
git commit -m "Brief description of the changes made"
- Edit a couple of your files with some new content
- Check the status of the repository with
git status
Note that your files are now marked as modified
- Stage your files for the next commit
- Use
git add .to stage any modified files
- Commit your new changes
- Use
git commit -m "Brief description of the changes made"
- View the history of commits
- Use
git logto view the history of commits made
- Try removing
file3.txtfrom your repository withgit rm file3.txt - Try renaming one of the remaining files with
git mv
Hey! Thanks for taking the time to document this and all the work you have done! I just translate this guide to spanish for a course.