Packages installed via the Emacs package manager are stored in the
elpa directory. If you exclude that directory you won't have any package files in your git repository.
The only other consideration is that you may need to modify your init file, in case there's code in there that requires packages only available on one or the other of your machines. If that's the case, you'll need to do something like:
(when (string= (system-name) "my-home-computer")
<code that only runs on your home computer>)
Beyond this, some packages may create files or directories in
~/.emacs.d/, but there's no general rule that would allow you to identify them. However, when this happens it's usually a way for the package to store data that is used by the package code, but not any actual code. Storing these files in git won't cause you any problems.
For example, in my
~/.emacs.d/ I have a directory created by
auctex, which contains style information used by
auctex in different situations. If that file got synced to a computer that didn't have
auctex, it wouldn't cause any problems, as no other code would use it. (
auctex may not be a great example as I think it's installed by default)
I also have a
snippet directory created/managed by the
yas-snippet package, which is similarly inert on a machine that doesn't have
If you're really concerned about space, you need to go through your
~/.emacs.d/ directory 'by hand' and figure out where everything there came from. But in practice, only
~/.emacs.d/elpa has any real impact on what gets loaded and used by emacs packages.