setting up a remote repository

Imagine you have a project directory project, and you’d like to use git for version control.

Make the initial commit

cd project
git init
git add -A
git commit -m "initial commit - adding everything"

Clone the bare git directory

cd ..
git clone --bare ./project project.git

Recursively copy the bare git repository to the server.

scp P <port> -r ./project.git user@server:/opt/git/project.git

Add the repository to your list of remotes using the standard user@server:port format.

cd ./project
git remote add origin ssh://user@server:port/opt/git/project.git
git remote -v

Check the remote

git remote show origin

reverting changes to HEAD for a single file

To revert changes for a given file to the latest commit (i.e., HEAD):

git checkout filename

If the file you wish to revert happens to be the name of a branch:

git checkout -- filename

Check out the git book for further details.