14 Undoing Changes Before Committing
14 Undoing Changes Before Committing
Command:
1
2
$ cd scripts
$ vim all_checks.py
File with code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/env python3
import os
import sys
def main():
if check_reboot():
print("Pending Reboot.")
sys.exit(1)
print("Everything ok.")
sys.exit(0)
main()
Command:
1
$ ./all_checks.py
Code output:
1
2
3
4
5
6
7
8
9
10
11
Traceback (most recent call last):
File "all_checks.py", line 14, in <module>
main()
File "all_checks.py", line 7, in main
if check_reboot():
NameError: name 'check_reboot' is not defined
Command:
1
$ git status
Code output:
1
2
3
4
5
6
7
8
9
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: all_checks.py
Command:
1
2
$ git checkout all_checks.py
$ git status
Code output:
1
2
3
On branch master
nothing to commit, working tree clean
Command:
1
$ ./all_checks.py
Code output:
1
Everything ok.
Command:
1
2
3
$ ./all_checks.py > output.txt
$ git add *
$ git status
Code output:
1
2
3
4
5
6
7
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: output.txt
Command:
1
2
$ git reset HEAD output.txt
$ git status
Code output:
1
2
3
4
5
6
7
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
Output.txt
Command:
1
git commit -m "it should be os.path.exists"
This post is licensed under CC BY 4.0 by the author.