alex's thinkery

Git: get me out of the trouble!

Git: get me out of the trouble!

git essential Mar 28, 2013

Useful for seeing changes from remotes: git log HEAD..origin/master

See what has been changed in the last commit: git log --stat HEAD...HEAD~1

Undo the last commit: git reset --soft HEAD^

Revert some files to older revisions: git co revision file1 file2

Your branch is ahead of 'origin/master' by 4 commits.
don't push this to master but rather to a new branch:
git checkout -b newbranch
git checkout -b newbranch
git push origin newbranch
git checkout master
git reset --hard origin/master

(undo the changes on the master branch, the commits to get to newbranch stay intact, it looks like the branch was started at the point of the last push)

Create a new repository with server sync:

git init
git add files
git commit -m "first commit"

sudo mkdir /var/git/repo
sudo chown alex:users /var/git/repo
cd /var/git/repo
git init --bare

git remote add origin ssh://server/var/git/repo
git push --set-upstream origin master