Of Code and Me

Somewhere to write down all the stuff I'm going to forget and then need

Generate a changelog for the current branch in Git September 2, 2011

Filed under: Git — Rupert Bates @ 3:04 pm

I find it useful to be able to quickly generate a list of all changes in the current branch which have not yet been merged into master. It’s a good way to come up with a change list when doing a release for instance. To do this in git you can use the following:

git log master.. --pretty="%s"

This assumes that you are on a branch which is off master (if you are on master you could use the path ..my-branch) and that the changes have not yet been merged into master, and it will give you a list showing only the commit messages, ready for copying and pasting into that release note.

 

Commit working directory changes to a new branch in git July 1, 2011

Filed under: Git — Rupert Bates @ 3:30 pm

To create and checkout a new branch in git taking any uncommitted changes with you use:

git checkout -b my_new_branch

 

Error .apk.res not found In IntelliJ Idea Android project January 27, 2011

Filed under: Android,Error,Git,IntelliJ,Java — Rupert Bates @ 10:32 am

After pulling the latest source of an android project I am working on from GitHub I got the following error:


MyProject.apk.res not found. Try to rebuild project

But no amount of rebuilding would fix it.
It turned out that the problem was that somehow the Module had lost track of which Android platform it is targeted to. To fix it I did the following:

  1. Bring up the Project Structure dialog (File/Project Structure or ctrl+alt+shift+s)
  2. Make sure that Modules is selected in the Project settings pane (far left)
  3. Expand the node with the name of your project in the middle pane and click on the Android node underneath it. This selects the Android facet.
  4. At the top of the Facet pane there is a drop-down list which you can use to select your Android platform. If there are no entries in this you can create a new one by clicking ‘New’ and locating the directory your Android SDK is installed in.
  5. Click Ok and rebuild, the problem should now be fixed

It seems that the problem is caused by Git in some way, but I’m not exactly sure how yet. I’ll update here if I find out why.

 

Avoid checking in connection strings and other sensitive config information to Github December 21, 2010

Filed under: Git — Rupert Bates @ 12:25 pm

In order to avoid checking in connection strings and other sensitive configuration information to Github I use the following approach:

Check your config file in with blank or dummy values then run:

git update-index --assume-unchanged [fileName]

Git will then stop monitoring changes to that file allowing you to put the real config info into it without fear of checking it in.

If you later make changes that you DO want to check in you can run:

git update-index --no-assume-unchanged [fileName]

But obviously make sure you blank out the sensitive information before checking in, and re run the assume-unchanged command afterwards.

 

How to include dlls added by NuGet package manager in a git repository November 26, 2010

Filed under: Git,Visual Studio — Rupert Bates @ 9:28 am

If you have excluded dll files from your git repository with your .gitignore file but DO want to include them when they have been added via the NuGet package manager, you can add this after the dll exclude.

# Include dlls if they’re in the NuGet packages directory
!/packages/*/lib/*.dll

 

Remove all staged changes from a git index July 16, 2010

Filed under: Git — Rupert Bates @ 11:27 am
git rm -r --cached .
 

The .gitignore file I use with Visual Studio projects March 26, 2010

Filed under: Git,Visual Studio — Rupert Bates @ 7:48 pm

This seems to keep most of the crap out and I haven’t found anything necessary that it excludes yet.

# compiled source #
###################
*.com
*.class
*.dll
*.exe
*.pdb
*.dll.config
*.cache
*.suo

# Include dlls if they’re in the NuGet packages directory
!/packages/*/lib/*.dll

# VS Upgrade stuff #
####################
UpgradeLog.XML
_UpgradeReport_Files/

# Directories #
###############
bin/
obj/
TestResults/

# Web publish log #
###################
*.Publish.xml

# Resharper #
#############
/_ReSharper.*
*.ReSharper.*

# Packages #
############
# it’s better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Logs and databases #
######################
*.log
*.sqlite

# OS generated files #
######################
.DS_Store?
ehthumbs.db
Icon?
Thumbs.db