-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-git-push.sh
executable file
·40 lines (32 loc) · 1.08 KB
/
test-git-push.sh
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
#!/bin/bash
set -e
# Create a temporary directory for testing
TEST_DIR=$(mktemp -d)
echo "Created test directory: $TEST_DIR"
cd "$TEST_DIR"
# Set up a local Git repository
echo "Setting up local Git repository..."
git init
git config --global user.name "Test User"
git config --global user.email "[email protected]"
# Create a test file and add it to the index (staging area)
echo "Creating test file and adding it to the index..."
echo "Initial content" > test-file.txt
git add test-file.txt
# Detach HEAD to simulate GitHub Actions environment
git commit -m "Initial commit"
git checkout --detach HEAD
echo "Now in detached HEAD state"
# Make changes in detached HEAD (without committing)
echo "Making changes in detached HEAD (without committing)..."
echo "Updated content" > test-file.txt
git add test-file.txt
echo "Current Git status:"
git status
# Try pushing with the fixed command
echo "Attempting to push with the fixed command..."
git push origin HEAD:main
# Clean up
cd -
echo "Test completed successfully! The fix works."
echo "You can remove the test directory with: rm -rf $TEST_DIR"