Homebrew issues error while calling 'brew update' I don't have much knowledge of all this so please forgive my incompetence. When I run brew update, it shows:

fatal: Unable to create '/usr/local/Library/Taps/homebrew-science/.git/index.lock': Permission denied
Error: Failed to update tap: homebrew/science
Already up-to-date.


But, when I do sudo brew update, it says:

bash-3.2$ sudo brew update
Password:
Already up-to-date.


Why does it flag the fatal warning when I run the command without sudo? FYI, to provide some context I am trying to install Octave regarding which I need to run brew tap homebrew/science.  

Please let me know how should I fix this. If possible, kindly provide a link to a page/article where I can understand the reason for the warning.
The index.lock file which is located in a directory which might need root permission to modify it or its files. You can change the permission of a directory using the chmod command. 

This is what you can do:
sudo chmod -R +w /path/to/directory

A good choice for directory in this case might be '/usr/local/Library/Taps/'

The -R option will recursively execute the command on sub directories and files.

The +w option will add write permission to the mentioned directory or file for everyone.

Good Luck. ;)