git --version git version 2.7.0 (Apple Git-66) 1

git –version git version 2.7.0 (Apple Git-66)

$ git --version git version 2.7.0 (Apple Git-66)

Here is what the above code is Doing:
1. We’re using the subprocess module to run the git command.
2. We’re using the check_output() function to run the git command.
3. We’re passing the version argument to the git command.
4. We’re passing the –version argument to the git command.
5. We’re passing the universal_newlines=True argument to the check_output() function.
6. We’re using the decode() method to decode the output of the git command.
7. We’re using the strip() method to remove the newline character from the output of the git command.
8. We’re printing the output of the git command.

Similar Posts