This repository is section C of the GitRuler exercises. If you do not already have a your own repository for these exercises fork this repository.
In this exercise we will learn about moving and removing files within a repository and telling git to ignore a set of files.
If there are many files in our directories that we never want to track using git then we can tell git to ignore them. This often happens while programming because we don't want to commit compiled files.
Imagine that the text editor used by our shop-keeper creates backup files whenever he edits one. The files/ideas folder is full of these .bak files. Rather than having to keep deleting these and so that we can easily commit the ideas directory, we want git to ignore all of them.
There is also a files/ideas/drafts folder where he keeps files that are not yet ready to commit. We want git to always ignore files within this folder.
- Run GitRuler to initialise the exercise.
- Create the necessary file and contents so that git will ignore all files ending with
.bakin thefiles/ideasfolder and everything in thefiles/ideas/draftsfolder. - Commit this file with the commit message "Ignore draft and backup ideas".
- Commit all of the
.txtfiles in thefiles/ideas/folder (you should now be able to stage them all with a singlegit addcommand) with the commit messages "Add extra ideas".
It's decided to create a folder for great ideas and to remove some of the worst ones.
- Create a folder
files/ideas/great(this is not a git action just creating a folder on your machine). - Use git to move
new-website.txt,better-signs.txtandput-locks-on-the-doors.txtto thefiles/ideas/greatfolder. - Commit the moved files with the message "Move great ideas".
- Remove the files
smaller-plums.txtandblue-uniforms.txtfrom git and commit this with the message "Remove bad ideas". - Commit the removal of files with the message "Remove bad ideas".
Once the exercise is complete, push this repository to the remote. If there are multiple branches for an exercise, make sure that you push them all.
To ensure that you have you correctly pushed everything that you need to, you could clone the remote repository into a separate folder and re-run gitruler.
- There are many resources about how to tell git to ignore files or folders. One example is in the Atlassian git tutorial
- There are also many resources for moving and removing files. Just Google.