Q:

Link command line tf checkin to work item

I'd like to commit a file to TFS repository through the tf command-line tool and link the commit to a TFS work-item.  How do I do it?
I've gotten as far as committing my file, but without a link to the work-item.  
My command adds a new file and commits the changes:
%> tf add foo.cpp
%> tf checkin foo.cpp -comment:"this is cool, but no work-item!"

A:

Unfortunately, you can not do this using tf.exe command line. If you need to use the -noprompt parameter for automation then you're likely out of luck.
Without -noprompt parameter, simply do this in work-item bar from UI. Select the workitem from your query and check the √, finally check in changes.

If this is a checkin policy in your company, you could also use the override parameter to bypass it as a workaround.
tf.exe checkin c:\workSpaceFilepath /comment:"some comment" /override:"Automated Build Process"

More details  please take a look at this similar question: Can I check in to TFS from CLI with a work item association? 

Update
tf checkin -associate

May do the trick as KlingonJoe says. However - associate is out of date
This may work with earlier version of TFS\VS such as VS2010 or team explorer everywhere. But it's not work for TFS2015 and VS2013 and above at least. 
Moreover, to ignore the prompt, you could directly use /noprompt  in your tf check in command. More info you could check this tutorial.

