-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_commit.py
More file actions
52 lines (42 loc) · 2.01 KB
/
git_commit.py
File metadata and controls
52 lines (42 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import subprocess
import os
os.chdir(r'E:\DL FInal')
print("=" * 70)
print("COMMITTING AND PUSHING CHANGES TO GITHUB")
print("=" * 70)
# Check if images folder is being tracked
print("\nRemoving images folder from git tracking (if previously added)...")
subprocess.run(["git", "rm", "-r", "--cached", "images"], capture_output=True)
subprocess.run(["git", "rm", "--cached", "setup_and_commit.bat"], capture_output=True)
subprocess.run(["git", "rm", "--cached", "install_and_commit.py"], capture_output=True)
print("\nAdding .gitignore and updated files...")
subprocess.run(["git", "add", ".gitignore", "README.md"])
print("\nCommitting changes...")
result = subprocess.run([
"git", "commit", "-m",
"Add .gitignore to exclude images and provide dataset link\n\n- Exclude images/ folder from repository (large dataset)\n- Add comprehensive .gitignore for Python and Jupyter files\n- Update README with clear setup instructions and dataset download link\n- Remove temporary installation scripts from git tracking\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>"
], capture_output=True, text=True)
print(result.stdout)
if result.stderr:
print(result.stderr)
print("\nPushing to remote repository...")
result = subprocess.run(["git", "push"], capture_output=True, text=True)
if result.returncode == 0:
print("✓ Successfully pushed to GitHub!")
print(result.stdout)
if result.stderr:
print(result.stderr)
else:
# Try setting upstream
print("Setting upstream branch...")
result = subprocess.run(["git", "branch", "--show-current"], capture_output=True, text=True)
branch = result.stdout.strip()
result = subprocess.run(["git", "push", "-u", "origin", branch], capture_output=True, text=True)
if result.returncode == 0:
print(f"✓ Successfully pushed to origin/{branch}!")
print(result.stdout)
else:
print("Error:", result.stderr)
print("\n" + "=" * 70)
print("DONE! Images folder excluded, dataset link provided in README")
print("=" * 70)