![]() ![]() Here is a hack to enable Git on Windows Command Prompt that works seamlessly with Github Desktop, in the case Git was installed along with GitHub desktop. Which kind of sucks if you want to recover discarded stashed changes, for example. Discarded files placed in the Windows Recycle bin.The use of a shell command prompt to directly enter command lines.Indeed, the latest versions of Github Desktop (I use 2.9.6) on Windows 10 no longer enables: Git config core.editor "'C:\Program Files (x86)\Notepad++\notepad++.exe' -multiInst -notabbar -nosession -noPlugin" I fixed it by typing the following in the power shell: Somehow the powershell opened by the old Github Desktop still had its core.editor set to vim. It is NOT enough to just install the new version of git and select notepad as editor. For me thats perfect as I use the new Github Desktop anyways for anything but opening the shell. Note that if you delete the git.exe, Github Desktop v3.3.4.0 will stop working and the only thing you can use it for is to open the shell. Since I had installed the Git separately in the newest version, it seems to default back to that and I get So if you are stuck with the old Github Desktop Chocolate-Covered Yaks because you like the powershell option and you want to upgrade to a newer version of GIT, then you should look for a folder like this:Ĭ:\Users\cmd folder. Unfortunately the new Github Desktop does not (yet) include a right click option to start PowerShell, like the old version did. Github Desktop was changed from Chocolate-Covered Yaks (newest version 3.3.4.0) to a new native desktop which was redesigned with Electron. $ git commitIf you are looking for the command line version of GIT with powershell and not CMD prompt like I was then this might help you. ![]() # Unstash changes to the working tree that we had stashed # Stash any changes to the working tree that are not going to be committed This is the correct pre-commit script: #!/bin/sh Solution to this problem is to stash all changes that are not part of the staging area before running our checks and then popping them back. # IT PASS THE CHECKS BUT IT'S NOT STAGED FOR COMMIT !Īs you can see, the problem is that pre-commit script was checking the README.txt file in our working tree but those changes are not in the staging area yet. # modified: README.txt <- THIS FILE WAS TESTED BY pre-commit SCRIPT, " to discard changes in working directory) We forgot to do git add README.txt which add the file to the staging area, but the pre-commit script didn't stop us, so we were going to leave an empty file in the repository.Ībort the commit with an empty message and check the status of the repository. your editor is open now, waiting for the commit message. $ echo "This is a repository for testing thing out." > README.txt # Broken version, it check the working tree instead of the staging areaĮcho "Error: README.txt file is missing or empty."Īdd a README.txt to your repository and try to commit your changes: $ touch README.txtĮrror: README.txt file is missing or empty.Īs you can see the pre-commit script abort the commit because the file is empty, it doesn’t even open your favourite editor to type in the message, so add some content and commit again. # Abort commit if README.txt is missing or empty It is usually a good idea to have a README.txt file, so we can use a simple pre-commit hook that abort the commit if the README.txt file is missing or empty.Ĭopy the following script in the ~/.git_template/hooks directory. Let see an example, first create a test repository and do the first commit: $ cd /tmp The problem is that they are testing the files in the working tree instead of the ones that are in the staging area, which means that you may committing files that actually don't pass the checks. You can find a lot of pre-commit scripts on the web but be aware that they may be wrong. A non-zero exit status of pre-commit script will abort the commit. It is used to check the changes that you're committing, to make sure tests runs, to remove pdb code, or whatever you need to inspect in the code. A pre-commit hook is a script that runs before every commit, even before you type in a commit message, and determines whether or not the commit should be accepted. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |