Skip to content

example how to add a document using command line git

Pete R Jemian edited this page Jun 15, 2015 · 1 revision

add document to EPICS Motor Working Group repository

Add a document that shows what EPICS motor record fields are used BY SPEC's EPICS_M2 motor support driver. Content is from an email from the SPEC developer to APS, saved in file

~/beamlines/bcda/Re:\ EPICS\ motor\ fields\ used\ by\ spec.eml

start a web browser (to learn the clone URL)

/usr/bin/firefox &

clone the github repository

cd /tmp
git clone https://github.com/EPICS-motor-wg/epics-mwg-discussions.git
cd epics-mwg-discussions/

note

Here's what we actually did (not what we intended to do). Instead of making our addition on a new branch, we added the file directly to master branch.

add the new file

Copy the file and give it a sensible name.

cd documents/
cp ~/beamlines/bcda/Re:\ EPICS\ motor\ fields\ used\ by\ spec.eml  Spec_motor_fields.txt
git add  Spec_motor_fields.txt
git commit -m "fixes #3"

BUT, we have just committed to the master branch. We should have done this work on a separate branch. Need to back this out. Looks like we did it the hard way.

revert to last good revision

Used web browser to identify the last good revision hash code: 58f437e

First, move the content we wish to add to a temporary safe place.

cp Spec_motor_fields.txt /tmp/

Next, reset to the last good revision hash tag.

git reset --hard 58f437e
git commit -m "Undo previous commit"

Rebase defines this as the current changeset, ignoring any later commits.

git rebase

Send our repository back to GitHub, forcing it to be accepted.

git push -f

Create new branch, add content, and push back to GitHub

Now, create (-b) and checkout (-t) remote tracking branch for our issue #3 on GitHub. (The -t option allows us to push back to GitHub more easily.)

git branch -b -t issue_3

Add our content

cp /tmp/Spec_motor_fields.txt .
git add Spec_motor_fields.txt
git commit -m "Fixes #3 again"
git push

Set our checked out branch back to master.

git checkout master

Finally, use web browser at GitHub and make a pull request from the issue_3 branch. Someone else on the project will review our work and decide whether or not to accept the pull request (that is, merge our branch with the master) or to explain why it is not accepted.