GIT tips and tricks

yehster wrote on Friday, November 09, 2012:

In response to Pimm’s question about undoing commits in another thread I thought I’d start this one. Folks will hopefully discuss and share hints.

Regarding “undoing” commits.

git reset --hard HEAD~1

This will rollback one commit on your local repository. 

if you try

git diff HEAD~1

This will show you exactly what code you are going to revert if you issue the reset command.

bradymiller wrote on Friday, November 09, 2012:

Hi,

Placed a link to this forum thread on the wiki page here: http://www.open-emr.org/wiki/index.php/Git_for_dummies#Tips_and_Tricks_and_Tools_that_are_useful

The nice thing about git is that nothing is ever really lost after it is committed. For example, if you did above command and realized you wanted the commit back, you could do:

git reflog

Find the sha number (number on the left column) on the item below the top row (top row should have ’ HEAD~1: updating HEAD’), and do:

git reset --hard <sha number>

-brady
OpenEMR

yehster wrote on Saturday, November 10, 2012:

Q1. Where are you seeing that your one commit was pushed to master?

Q2. The five integration developers, Brady, Rod, Stephen, Tony and Myself are the only ones who can push changes to master.  When a commit gets brought into the master branch, if it wasn’t implemented originally by one of the integration developers, github reports “committed by <someone>” in the description after the “authored by <someoneelse>”.
As an example:
https://github.com/openemr/openemr/commit/36e7915d6f05d98d7edf798d5f06f24947116d7f

anilnakkani authored November 06, 2012 bradymiller committed November 06, 2012 

No code gets into the master branch without a “manual approval” step by an integration developer. 
It is impossible to “do something that I should not have” that will impact the master branch by just issuing command to git/github.

Q3. If you have a change in github you’d like to share. I think it’s best to make an announcement here in the developer’s forum with a link to the commit in github.  You can also post  in the tracker.  Just committing code to your own repository is not sufficient to get it into the master code base.

blankev wrote on Tuesday, November 13, 2012:

Please find a commit here:

https://github.com/blankev/openemr-1/commit/9c224a89228d985f4fc63771f8d8a2543060cf35

Really don’t know if it is an addition, but at least I think that I might learn to understand GitHub a bit better.

Question, if in the xlm(’ name’, ‘e’), does the “e” stand  for English translation fields?

Tnx for the support! Pimm

blankev wrote on Tuesday, November 13, 2012:

https://github.com/blankev/openemr-1/tree/master/library/classes

this was committed to GitHub, but I don’t know who accepted the code and who did help me to get it into the official OpenEMr 4.1.1. release……

Please give me some more insight of what happened?

Tnx, Pimm

bradymiller wrote on Tuesday, November 13, 2012:

Hi Pimm,

First thing to do is to clean up your repo a bit. Can you paste the content in the .git/config file here (there shouldn’t be any confidential info in there, but look through it before pasting it here); then can provide some commands to clean up your repo a bit and set some end of line settings. Also, are you using Linux or Windows?

And regarding the e setting, this is considered to be deprecated. It basically means the string will be echoed. So, basically:
echo xl(‘name’);
is the same as:
xl(‘name’,‘e’);

We suggest not using this parameter anymore because it overly complicates the translation/escaping combination functions, which are xlt() and xla(). Here’s some wiki pages to look at:
http://www.open-emr.org/wiki/index.php/Development_Policies#Internationalization
http://www.open-emr.org/wiki/index.php/OpenEMR_Internationalization_Development_Guide
http://www.open-emr.org/wiki/index.php/Codebase_Security#Plan (see STEP 4)

-brady
OpenEMR

bradymiller wrote on Tuesday, November 13, 2012:

Hi Pimm,

You committed it to your personal local and remote (on github) repos. Note your above link has blankev in the path, since you are using your repo. This is yours and nobody else can use it. Note the official OpenEMR repo is here:
http://github.com/openemr/openemr
(and only a few of us have access to modify this repo; it actually gets mirrored from the official OpenEMR repo on Sourceforge).

-brady
OpenEMR

blankev wrote on Tuesday, November 13, 2012:

Is my understanding correct?

Delete my GitHub as is and open a new GitHub repository?

Don’t expect major changes, but you might expect some field and labels that are incorrectly used or labeled.

Just experiencing and wnat to explore my knowledge from the book:

PHP, MySQL and Apache

I am using the Wondows option as promoted by GitHub. I still don’t get the commands from Linux versions. I want to do too much and learn tooo little…. Stupid, btut that’s the way I try to solve my OpenEMR problems.

Tnx, Pimm

bradymiller wrote on Tuesday, November 13, 2012:

Hi Pimm,

I wouldn’t delete your repo, since you have work in there.

Can you get to a command line at all from the windows version? I’m glad to supply the commands you’ll need to straighten things out a bit. But need the content of your.git/config file (this can be found in the the openemr-1 directory.

-brady
OpenEMR

blankev wrote on Tuesday, November 13, 2012:

I changed a label in referral _template. html and the label template for the html fie.

<span class=‘subhead’>{label_subhead_clinic}</span>
   </td>
   <td align=‘right’ width=‘10%’ valign=‘top’ nowrap>
    <table border=‘1’ cellpadding=‘2’ cellspacing=‘0’>
     <tr>
      <td nowrap>{label_clinic_id}</td>
      <td style=‘width:60pt’ nowrap>{fac_facility_npi}</td>
     </tr>
     <tr>
      <td nowrap>{label_pt_clinic_id}</td>

      <td nowrap>{ref_pid}</td>
     </tr>
     <tr>
      <td nowrap>{label_control_no}</td>

Is this enough for reference in both files or do you need the complete files that both had only one line changed?

Added {label_pt_clinic_id} in another file with the labels for the html file.

tmccormi wrote on Tuesday, November 13, 2012:

Windows versions have a feature called GitBash for command line operations.
-Tony

blankev wrote on Tuesday, November 13, 2012:

I check off  GitBash in Github and there is a mark next to GitBash, but it is as if nothing changed.

What is the next step?

bradymiller wrote on Tuesday, November 13, 2012:

Hi Pimm,

Our time is better spent helping you use git/github to submit code (note that we can test/submit code that is in git within minutes whereas manual changes, as above, take much longer).

-brady
OpenEMR

bradymiller wrote on Tuesday, November 13, 2012:

Hi,
From memory (I installed git/gitbash on windows a long time ago), I think you should have a gitbash shortcut on your desktop. If so, click it and then a command line should open up.
-brady

blankev wrote on Tuesday, November 13, 2012:

Ok, so far so good, they named it: Git Shell and it gives a command line. Now what shall I do?

Tell me if you can spend your time better, since I don’t have a clue of what I am doing. I miss the User Interface……

blankev wrote on Tuesday, November 13, 2012:

I found this somewhere in my local Github Directory:      -     .git   -  subdirectory

repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly

fetch = +refs/heads/*:refs/remotes/origin/*
url = https://github.com/xxxxxxxx/openemr-1.git

remote = origin
merge = refs/heads/master

remote = origin
merge = refs/heads/rel-411

bradymiller wrote on Tuesday, November 13, 2012:

Nice,

Is there a string on the command line prompt (the string to the left of where you enter in text)? If so, what is it?

Also, try to type:
git status

-brady

yehster wrote on Tuesday, November 13, 2012:

I would create a new empty directory at this point and change into it.  (Not sure if you have a bash shell or a regular command prompt at this point.)
the do:

git clone git@github.com:openemr/openemr
cd openemr
git branch referral_change
git checkout referral_change

At this point you have a fresh repository and a new branch to track the changes you want to make.  You should always make changes/updates in a branch that is separate from the master.
If everything makes sense, seems to be working at this point, what you can do is copy the referral_template.html file from your other directory into this source file tree.
At this point issue the command

git diff

It should show you what has changed from the original.
If all this makes sense, then the next step would be to explain how to “publish” your changes so the rest of us can see.

blankev wrote on Tuesday, November 13, 2012:

Let us see if I did it correct:

Show me how to publish!

Pimm

yehster wrote on Tuesday, November 13, 2012:

If all of the commands I suggested worked, then try this

git add .
git commit -m "referral changes"
git push git@github.com:blankev/openemr-1 referral_change