GIT: Difference between revisions

From CLONWiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
We are using 'github' as our online code management. It is owned by Sergey Boyarinov and managed from the site 'github.com' with username boiarino17.
We are using 'github' as our online code management. It is owned by Sergey Boyarinov and managed from the site 'github.com' with username boiarino17.
There are repositories: '''coda''', '''clon''', '''epics'' etc'.
There are repositories: '''coda''', '''clon''', '''epics''', '''parms''' etc.





Revision as of 22:23, 27 November 2013

We are using 'github' as our online code management. It is owned by Sergey Boyarinov and managed from the site 'github.com' with username boiarino17. There are repositories: coda, clon, epics, parms etc.


Basic Info

To use it clon clon machines, proxy have to be set by following command:

git config --global http.proxy jprox.jlab.org:8081

To get repository (for example coda) use following command:

git clone https://github.com/boiarino17/coda

Command git pull can be used to get files from repository.

Use following to add all files locally, usually used once initially.

git add .
git commit -a -m "first commit"

Removing files/directories example:

git rm src/bosio/bosio.s/SCCS/*
git commit src/bosio/bosio.s/
git push

Use git commit command to check in locally, and git push to check into repository.


Viewing Project History

At any point you can view the history of your changes using

git log

If you also want to see complete diffs at each step, use

git log -p

Often the overview of the change is useful to get a feel of each step

git log --stat --summary


Managing Branches

A single Git repository can maintain multiple branches of development. To create a new branch named "mycoda", use

git branch mycoda

If you now run

git branch

you'll get a list of all existing branches:

* master
  mycoda

The "mycoda" branch is the one you just created, and the "master" branch is a default branch that was created for you automatically. The asterisk marks the branch you are currently on; type

git checkout mycoda

to switch to the experimental branch. Now edit a file, commit the change, and switch back to the master branch:

(edit file)
git commit -a
git checkout master

Check that the change you made is no longer visible, since it was made on the experimental branch and you're back on the master branch.

You can make a different change on the master branch:

(edit file)
git commit -a

at this point the two branches have diverged, with different changes made in each. To merge the changes made in mycoda into master, run

git merge mycoda

If the changes don't conflict, you're done. If there are conflicts, markers will be left in the problematic files showing the conflict;

git diff

will show this. Once you've edited the files to resolve the conflicts,

git commit -a

will commit the result of the merge. Finally,

gitk

will show a nice graphical representation of the resulting history.

At this point you could delete the mycoda branch with

git branch -d mycoda

This command ensures that the changes in the mycodal branch are already in the current branch.

If you develop on a branch crazy-idea, then regret it, you can always delete the branch with

git branch -D crazy-idea

Branches are cheap and easy, so this is a good way to try something out.