How to add user upload files to git when the node is pulished?
You can take advantage of the Version control api


  Version Control API is an engine for Drupal integration with a variety
  of version control systems. The focus is primarily on working with
  canonical, server-side repositories. It provides basic tools that
  allow for things like history listings, commit access controls,
  triggered actions when new code comes in, and direct on-disk
  repository management.
  
  This module is a core engine and does nothing on its own without a
  "backend" module that provides integration with a specific VCS (e.g.
  git, bzr, svn). This module provides a consistent base interface (UI
  and API) for interacting with all the different backends.


You will also need the version control git backend as the module does not work on it's own


  This module provides an implementation of the Version Control API that
  makes it possible to use the Git version control system. It can
  retrieve commit information by parsing commit logs.
  
  The Git backend depends on the Version Control API module. It also
  requires Git >=1.7.2 to be installed on the server.