- The main focus of Git is to track changes to files over time. To view all changes committed to a repository over a certain time period, we can use the Git log command.
- The git log command shows a list of commits in reverse chronological order. This will show the hash of the commit, author, commit message, and date on which it was made.
Git Ignore Lists – Ignore files allow you to tell git what files never to track. Ignore files are made up of parents that match the names of files to ignore. Useful for ignoring build and runtime artifacts, for example, binary files or log files. Git ignores files are text files called .gitignore contained in the repository.
cat example.log – to show the contents of the file.
vi .gitignore (*.log)
Once changes have been made in the repository, we will want to save those changes. To do this, we use the Git commit command.
git commit begins the commit process. This opens the text editor specified by your git config or the EDITOR environment variable. Default commit message template contains the output of the git status. Pass –v to git commit to showing the current diff in the message template. Pass –a to git commit to add all changes and commit simultaneously. Use git commit –m “My commit message” if you don’t want to use an editor.
We have learned how to view the names of changed files using git status.
How do we view the exact changes we made since the last commit?
The git diff command allows us to do this.
In order for Git to start looking for changes to files, we have to add them to the Git repository. This allows Git to then track the changes made to those files over time.
Files are untracked when first created so that we don’t track unnecessary files. To start tracking, we use the git add command. Git add is short for “stage all files and changes in the current folder". To add a file’s changes to the staging area, we also use git add.
Please do below steps:
- Initializing turns a folder on your local machine into a git repository.
- The git init command creates a .git folder within the current directory.
- The .git folder contains everything you need to track changes to files.
- ls –a - Lists files and directories including hidden in the current path.
See below image as the practical snapshot.
VI is a very powerful command-line text editor available on almost all machines. We are going to use it to edit commit messages on the command line. This term is also known as the visual editor.
Below are the basic commands used to Manipulate Files and Folders. Manipulate in the sense create, move, update and delete/remove.
It is a fundamental skill that is necessary for using Git. It allows you to move between directories like create, delete, move and rename files and directories, and even modify files contents.
Below are basic commands to navigate File System.
Why use the terminal instead of Graphical User Interfaces (GUIs)? – Not all machines that you work on will have your GUI of choice. Learning the terminal means you can work anywhere. Git for the terminal has all the commands, whereas GUIs may only provide a subset.
The terminal’s capabilities are it can be used to do anything with your computer.
For example, create files, connect to other machines, or download things from the internet. It is text-based, hence faster than rendering graphics. Can be used on any machine.