Git

How to browse Project History?

Submitted by Rajasekhar on Sat, 11/10/2018 - 13:04
  1. 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.
  2. 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.

How to setup Git Ignore Files?

Submitted by Rajasekhar on Sat, 11/10/2018 - 13:01

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)

How to commit changes made to the file?

Submitted by Rajasekhar on Sat, 11/10/2018 - 12:57

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.

What is Tracking and How to Track Files?

Submitted by Rajasekhar on Sat, 11/10/2018 - 12:23

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.

How to configure and initializing a Repository?

Submitted by Rajasekhar on Sat, 11/10/2018 - 12:19

Please do below steps:

  1. Initializing turns a folder on your local machine into a git repository.
  2. The git init command creates a .git folder within the current directory.
  3. The .git folder contains everything you need to track changes to files.
  4. ls –a - Lists files and directories including hidden in the current path.

See below image as the practical snapshot.

What is the Terminal? Why Terminal?

Submitted by Rajasekhar on Sat, 11/10/2018 - 11:35

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.