简体   繁体   中英

Git commit hanging on 1kb file commit

Environment: Win8.1 using Git CMD

So I've been trying to nail down Git flakiness on my Windows machine. I'm able to clone a remote repo into a new fresh directory. The github repo contents were created on my Mac if that makes any difference. I add a 1kb text file to the Windows local called Add_file.txt. I appear to be able to add the file but not commit the file without git commit hanging.

How do I trace what is happening under the hood to figure out why I am not able to commit this? I have had repeated hangs attempting this procedure. If I kill ctrl+c at this point, a git lock file is left which prevents any further git commands on local. Deleting git lock file does not fix the inability to git commit.

Any ideas?

    C:\Users\mylocaluser\Documents\GitHub>git clone https://github.com/mygitaccount/99_Gitbug.git
    Cloning into '99_Gitbug'...
    remote: Counting objects: 11, done.
    remote: Compressing objects: 100% (7/7), done.
    remote: Total 11 (delta 1), reused 11 (delta 1), pack-reused 0
    Unpacking objects: 100% (11/11), done.

    C:\Users\mylocaluser\Documents\GitHub>cd 99_Gitbug
    C:\Users\mylocaluser\Documents\GitHub\99_Gitbug>git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    Untracked files:
      (use "git add <file>..." to include in what will be committed)

            Add_file.txt

    nothing added to commit but untracked files present (use "git add" to track)

    C:\Users\mylocaluser\Documents\GitHub\99_Gitbug>git add Add_file.txt

    C:\Users\mylocaluser\Documents\GitHub\99_Gitbug>git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    Changes to be committed:
      (use "git reset HEAD <file>..." to unstage)

            new file:   Add_file.txt


    C:\Users\mylocaluser\Documents\GitHub\99_Gitbug>git commit -m "6th commit to local WIN repo"

I am sure these are newb problems, however for the poor soul following me who is attempting to learn git, here my solutions encountered on my WIN8.1 machine. The exact syntax for each git command is included in sample code.

1) If cloning a remote repo fails on your Windows machine, try using the HTTP instead of HTTPS remote URL for your repo. HTTPS cloning outright failed for me.

    > git clone http://github.com/Agent-Sesame/99_Gitbug.git

2) If you are finding that git commit is hanging & failing on your Windows, try surrounding your commit status message with a ' tick mark instead of " quote mark. The tricky part about this convention is that " seems to be supported with git on Mac OSX.

    > git commit -m '6th commit from WIN'

Good luck~

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM