[Git] How to pass the first stage? Expected the ".git/HEAD" file to be created

Checklist:

  1. :white_check_mark: : I’ve uncommented the code.
  2. :white_check_mark: : I’ve saved the changes.
  3. :white_check_mark: : I’ve run the git commands:
git commit -am "[seeking help on forum]"
git push origin master

Here’s a screenshot showing the output from running the Git commands:

Expected the “.git/HEAD” file to be created can help me?

Hey @zuamsyah2, could you share a few screenshots to help us debug?

  1. The contents of your main.go file as shown in your code editor
  2. The output of running git status in your terminal
  3. The output of the following commands:
git commit -am "[seeking help on forum]"
git push origin master

This will help us get a better sense of what’s going on. Thanks!

  1. package main
    
    import (
    	"fmt"
    	"os"
    )
    
    // Usage: your_program.sh <command> <arg1> <arg2> ...
    func main() {
    	// You can use print statements as follows for debugging, they'll be visible when running tests.
    	fmt.Fprintf(os.Stderr, "Logs from your program will appear here!\n")
    
    	if len(os.Args) < 2 {
    		fmt.Fprintf(os.Stderr, "usage: mygit <command> [<args>...]\n")
    		os.Exit(1)
    	}
    
    	switch command := os.Args[1]; command {
    	case "init":
    		// Uncomment this block to pass the first stage!
    		//
    		for _, dir := range []string{".git", ".git/objects", ".git/refs"} {
    			if err := os.MkdirAll(dir, 0755); err != nil {
    				fmt.Fprintf(os.Stderr, "Error creating directory: %s\n", err)
    			}
    		}
    		//
    		// headFileContents := []byte("ref: refs/heads/main\n")
    		// if err := os.WriteFile(".git/HEAD", headFileContents, 0644); err != nil {
    		// 	fmt.Fprintf(os.Stderr, "Error writing file: %s\n", err)
    		// }
    		//
    		// fmt.Println("Initialized git directory")
    
    	default:
    		fmt.Fprintf(os.Stderr, "Unknown command %s\n", command)
    		os.Exit(1)
    	}
    }
    
    
  2. git push origin master
    On branch master
    Your branch is up to date with 'origin/master'.
    
    nothing to commit, working tree clean
    Everything up-to-date
    sholehzuamsyah@sholehzu
    
  3. On branch master
    Your branch is up to date with 'origin/master'.
    
    nothing to commit, working tree clean
    Everything up-to-date
    
    

@zuamsyah2 Could you try uncommenting the remaining part as well?

Let me know how it goes!