Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Saturday, October 29, 2011

Git on amazon ec2

Very quick solution, if you have a your_amazon_key.pem:
ssh-add /path/to/your_amazon_key.pem
After this git push proceeds successfully.

And a longer way.

Tuesday, September 6, 2011

Create GIT remote repository

# On local machine

cd foo_project
git init
git add *
git commit -m "My initial commit message"

# On remote machine (Git remote repository)

cd /var/git/
mkdir foo.git
cd foo.git
git --bare init

# On local machine

git remote add origin ssh://agolovatuk@example.com/var/git/foo.git
git push origin master
git checkout origin/master
git branch -f master origin/master
git checkout master

Some useful GIT tips

revert the last commit as it never was
# git reset --hard HEAD^

delete remote git branch
# git push origin :branchName

sync remote branches (removes tracking branch if remote branch was deleted)
# git remote prune origin

delete local branch links if they were deleted on origin
# git remote prune origin

create branch with a link to remote repository
# git checkout --track -b deployCandidate origin/deployCandidate

git config list
# git config -l

git show repository changes history
# git reflog
(to get to the some state run from reflog)
# git reset --hard HEAD@{0}

git show diff between what is commited (but not pushed) and the repository
# git diff HEAD^

colors in git put this to .git/config:
[color]
  branch = auto
  diff = auto
  status = auto
[color "branch"]
  current = yellow reverse
  local = yellow
  remote = green
[color "diff"]
  meta = yellow bold
  frag = magenta bold
  old = red bold
  new = green bold
[color "status"]
  added = yellow
  changed = green
  untracked = cyan