Posts

Showing posts with the label git

Sync Github Gists with Git Repo

Image
I needed an easy way to sync  github gists  to my local machines and I couldn't find anything provided by gist, or any other open source projects out there so I put this little node app together quick. Simply clone this repo and update the `users.json` file to sync all the associated public gists to your local machine. https://github.com/aaronhoffman/gists The node app uses the gists api  and `git clone`s each gist into a folder with the same name as it's id: Hope this helps! Aaron

git - protect local master branch, prevent commit and push

Image
If you've worked with a remote git hosting service like github , you're likely familiar with the concept of protecting a branch . Other remote git hosting services ( vsts , bitbucket , gitlab , etc) also support the concept. It's a good idea to protect your remote in this way, but why stop there? You can also protect your local dev environment from human error by using git hooks . A new git repo (`git init`) comes with various hook examples in the `.git/hooks/` directory. We can tie into two of those hooks, `pre-commit` and `pre-push`, to prevent commits to your local master branch, and to prevent attempting to push to the remote master branch (even from a local feature branch). Place the two files found in the gist linked below in your repo's .git/hooks directory to prevent the two actions described above: https://gist.github.com/aaronhoffman/ffbfd36928f9336be2436cffe39feaec Hope this helps, Aaron

Version your Visual Studio Builds by Git Commit Hash

Image
Semantic versioning is great, but more often than not, when I'm looking at a folder of deployed binaries, I want to know the git  commit   hash of the source code that was used to generate them (a versioned container might be better in some cases, but that's not applicable in every situation at the moment). A simple way to accomplish this is to generate a "version.txt" file at build time that will eventually be deployed with the code. Visual Studio makes it pretty easy to automatically generate this version.txt file with it's built in " build events ". Simply add the following line to the "Post-build event command line:" textbox, and a version.txt file will appear in your build output directory with the current commit hash after a successful build. "C:\Program Files\Git\bin\git.exe" rev-parse HEAD > "$(ProjectDir)$(OutDir)version.txt" If you'd like to generate this file after an Azure Kudu deployment, se