In this chapter we shall learn about below GIT commands.
* “git hooks” are custom scripts that run whenever a particular event occur.
* They are present in “.git/hooks” directory.
* Below are the sample files that you get:
* To use these hooks, remove the “.sample” extension.
* For example, in “pre-commit” you can write a script that will do a unit testing of the changes, so that the commit will not break anything.
* So this “pre-commit” hook will run, prior to commit.
“git ignore” is used to ignore some of the auto generated files or object files.
“.gitignore” file is used to ignore all the files that we dont want to be tracked.
We can put the list of files that are needed to be ignored.
If you have that file then open it or else to create the file, go to the local repository then “gvim .gitignore”
In git ignore file, we need to write only one expression per line, example shown below:
My “.gitignore” file is as below
In the current directory I have below files:
as we have put “filename.abc” file in “.gitignore”, it will not be tracked, we can see it in “git status” command.
* Similar to .gitignore, .gitattributes file is used to create a visual understanding of the files, when you do “diff”.
* You can follow below link for more .gitattributes settings for different languages.
* when you make a copy of remote repository that has many branches, and those branches will be copied to your local repository.
* When the remote repository will merge those branches, there is an option available in remote repository to delete that branch.
* To delete the local branches, we use “git prune”.
* To know the branch that are unreachable use “git remote prune origin –dry-run” command.
* To delete those branches use “git remote prune origin” command.
“git show <commit-id/sha>” command is used to show the metadata and content changes for the specified commit.