abandoned bytes
Engineering: the art of making what you want from things you can get.

GIT

August 30, 2009

Visualize:

~/project.git $ gitk --all

New repo:

~ $ mkdir project.git ~ $ cd project.git ~/project.git $ git init

Clone:

~ $ git clone git://gitorious.org/project/project.git ~ $ cd project ~/project $ git remote rm origin ~/project $ git remote add origin git@gitorious.org:project/project.git # ??? are these 2 needed?? ~/project $ git pull git://gitorious.org/project/project.git master # get it up2date

Push:

~/project.git $ git add newfile ~/project.git $ git commit -m "commit message" # git commit -a -m "commit message", if you made a change to a file ~/project.git $ git push origin master

Merge together with another branch:

~/project.git $ git checkout master # if you don't want it directly, create a branch and change to it before pulling ~/project.git $ git pull git://gitorious.org/~user/project/users-clone.git

General branching:

~/project.git $ git branch # local branches ~/project.git $ git branch -r # remote branches ~/project.git $ git branch -a # all branches

Create new local branch and work:

~/project.git $ git branch * master ~/project.git $ git branch new-branch ~/project.git $ git checkout new-branch ~/project.git $ ... ~/project.git $ git commit -a -m "commit message" ~/project.git $ git push # assuming we are done with the branch, and we want it in ~/project.git $ git checkout master ~/project.git $ git rebase new-branch ~/project.git $ git branch -d davids-first ~/project.git $ git push # assuming we don't want it anymore ~/project.git $ git checkout master ~/project.git $ git branch -D davids-first

Rebase:

~/project.git $ git branch master * new-branch ~/project.git $ git rebase master # advances new-branch to master ~/project.git $ git push

Remote branching:

~/project.git $ git push origin origin:refs/heads/new-branch # create new remote branch ~/project.git $ git checkout --track -b new-branch origin/new-branch # it isn't mandatory to call the ~/project.git $ ... # local branch the same, but why not? ~/project.git $ git push origin :heads/new-branch # we want to get rid of the crap we did (or we rebased master) ~/project.git $ git checkout master ~/project.git $ git branch -D new-branch
Last modified: August 30, 2009

Comments

No comments yet. Why don't you write the first one?

Write a comment

The fields e-mail and website are optional. Your e-mail-address will not be displayed, it's only for me to be able to reply.

Name:
E-Mail:
Website:

Fill in the CAPTCHA to prove you are human:

© 2009 by David Madl. Impressum | Home (English) | Home (Deutsch) | Processing time: 0.173 s | IPv4

abandoned bytes (en) > Software > Linux stuff > Git commands
User:
Pass: