Difference between revisions of "Annotated Git session using the sim-recon repository"

From GlueXWiki
Jump to: navigation, search
(Created page with " > From: Naomi Jarvis <nsj@cmu.edu> > Subject: git instructions / sim-recon gluex plugin update push pull > Date: December 11, 2015 at 5:11:11 PM EST > To: Naomi Jarvis <nsj@c...")
 
 
(21 intermediate revisions by the same user not shown)
Line 1: Line 1:
  
> From: Naomi Jarvis <nsj@cmu.edu>
+
I needed to update one monitoring plugin file, which was in a non-git directory in my home area.  This was the best way to go about it:
> Subject: git instructions / sim-recon gluex plugin update push pull
+
 
> Date: December 11, 2015 at 5:11:11 PM EST
+
Make a local copy of the entire sim-recon repository for myself.  This took about 5 seconds.  OR... be sure to checkout the master branch and update it.
> To: Naomi Jarvis <nsj@cmu.edu>
+
<pre style="color:darkblue">
>
+
cd ~
> I needed to update one monitoring plugin file, which was in a non-git directory in my home area.  This was the best way to go about it.
+
mkdir git
>
+
cd git
> Make a local copy of the entire sim-recon repository for myself.  This took about 5 seconds.
+
git clone https://github.com/JeffersonLab/sim-recon
>
+
</pre>
> cd ~
+
 
> mkdir git
+
Check that the plugin in the repository is what I think it is   
> cd git
+
<pre style="color:darkblue">
> git clone https://github.com/JeffersonLab/sim-recon
+
cd sim-recon/src/plugins/monitoring/CDC_online/
>
+
git status
>
+
</pre>
> Check that the plugin in the repository is what I think it is   
+
 
>
+
Copy in my updated file  
> cd sim-recon/src/plugins/monitoring/CDC_online/
+
<pre style="color:darkblue">
> git status
+
cp ~/online/plugins/CDC_online/JEventProcessor_CDC_online.cc .
>
+
git status
>
+
</pre>
> Copy in my updated file  
+
<pre style="color:darkred">
>
+
# On branch master
> cp ~/online/plugins/CDC_online/JEventProcessor_CDC_online.cc .
+
# Changed but not updated:
> git status
+
#  (use "git add <file>..." to update what will be committed)
> # On branch master
+
#  (use "git checkout -- <file>..." to discard changes in working directory)
> # Changed but not updated:
+
#
> #  (use "git add <file>..." to update what will be committed)
+
# modified:  JEventProcessor_CDC_online.cc
> #  (use "git checkout -- <file>..." to discard changes in working directory)
+
#
> #
+
</pre>
> # modified:  JEventProcessor_CDC_online.cc
+
 
> #
+
 
>
+
List the changes between this copy and the original and make sure that they are all mine (use space to get to next page)
>
+
<pre style="color:darkblue">
> List the changes between this copy and the original and make sure that they are all mine (use space to get to next page)
+
git diff
> git diff
+
</pre>
>
+
 
>
+
 
> Make a new branch to contain and label my change
+
Make a new branch to contain and label my change
>
+
 
> git branch cdcpluginupdate
+
<pre style="color:darkblue">
> git status
+
git branch cdcpluginupdate
> # On branch master
+
git status
> # Changed but not updated:
+
</pre>
> #  (use "git add <file>..." to update what will be committed)
+
<pre style="color:darkred">
> #  (use "git checkout -- <file>..." to discard changes in working directory)
+
# On branch master
> #
+
# Changed but not updated:
> # modified:  JEventProcessor_CDC_online.cc
+
#  (use "git add <file>..." to update what will be committed)
> #
+
#  (use "git checkout -- <file>..." to discard changes in working directory)
> no changes added to commit (use "git add" and/or "git commit -a")
+
#
>
+
# modified:  JEventProcessor_CDC_online.cc
>
+
#
> Switch to the new branch, check the status and list the branches.  
+
no changes added to commit (use "git add" and/or "git commit -a")
>
+
</pre>
> git checkout cdcpluginupdate
+
 
> M src/plugins/monitoring/CDC_online/JEventProcessor_CDC_online.cc
+
Switch to the new branch, check the status and list the branches.  
> Switched to branch 'cdcpluginupdate'
+
 
>
+
<pre style="color:darkblue">
> git status
+
git checkout cdcpluginupdate
> # On branch cdcpluginupdate
+
</pre>
> # Changes to be committed:
+
<pre style="color:darkred">
> #  (use "git reset HEAD <file>..." to unstage)
+
M src/plugins/monitoring/CDC_online/JEventProcessor_CDC_online.cc
> #
+
Switched to branch 'cdcpluginupdate'
> # modified:  JEventProcessor_CDC_online.cc
+
</pre>
> #
+
 
>
+
<pre style="color:darkblue">
> git branch  
+
git status
> * cdcpluginupdate
+
</pre>
>   master
+
<pre style="color:darkred">
>
+
# On branch cdcpluginupdate
>
+
# Changes to be committed:
> Add the file to the list of files to be committed/uploaded to the repository
+
#  (use "git reset HEAD <file>..." to unstage)
> git add JEventProcessor_CDC_online.cc
+
#
>
+
# modified:  JEventProcessor_CDC_online.cc
> git status
+
#
> # On branch cdcpluginupdate
+
</pre>
> # Changes to be committed:
+
<pre style="color:darkblue">
> #  (use "git reset HEAD <file>..." to unstage)
+
git branch  
> #
+
* cdcpluginupdate
> # modified:  JEventProcessor_CDC_online.cc
+
   master
> #
+
</pre>
>
+
 
> Tell git to use my username and email address that I used when joining the GlueX github team
+
Add the file to the list of files to be committed/uploaded to the repository
>
+
<pre style="color:darkblue">
> git config --global user.name "Naomi Jarvis"
+
git add JEventProcessor_CDC_online.cc
> git config --global user.email "nsj@cmu.edu"
+
 
>
+
git status
>
+
</pre>
> Commit change to the local repository
+
<pre style="color:darkred">
>
+
# On branch cdcpluginupdate
> git commit -m "updated cdc_online for fa125 new format"
+
# Changes to be committed:
>
+
#  (use "git reset HEAD <file>..." to unstage)
>
+
#
> Send it to the remote repository.  The first branchname given is the local name, the second is the new name on the remote repo (usually no need to change it).
+
# modified:  JEventProcessor_CDC_online.cc
>
+
#
> git push origin cdcpluginupdate:cdcpluginupdate  
+
</pre>
> error: The requested URL returned error: 403 Forbidden while accessing https://github.com/JeffersonLab/sim-recon/info/refs
+
 
> fatal: HTTP request failed
+
Commit change to the local repository
>
+
<pre style="color:darkblue">
> This did not work, check the age of git
+
git commit -m "updated cdc_online for fa125 new format"
>
+
</pre>
> git —version
+
 
> git version 1.7.1
+
Send it to the remote repository.  The first branchname given is the local name, the second is the new name on the remote repo (usually no need to change it).
>
+
<pre style="color:darkblue">
> Try again from a different computer with a more recent git, as 1.7.1 is known to be problematic
+
git push origin cdcpluginupdate:cdcpluginupdate  
>
+
</pre><pre style="color:darkred">
> git —version
+
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/JeffersonLab/sim-recon/info/refs
> git version 2.5.0
+
fatal: HTTP request failed
>
+
</pre>
> git push origin cdcpluginupdate:cdcpluginupdate  
+
This did not work, check the age of git
> Counting objects: 7, done.
+
 
> Delta compression using up to 4 threads.
+
<pre style="color:darkblue">
> Compressing objects: 100% (7/7), done.
+
git —-version
> Writing objects: 100% (7/7), 1.43 KiB | 0 bytes/s, done.
+
</pre>
> Total 7 (delta 6), reused 0 (delta 0)
+
<pre style="color:darkred">
> To https://github.com/JeffersonLab/sim-recon
+
git version 1.7.1
> * [new branch]      cdcpluginupdate -> cdcpluginupdate
+
</pre>
>
+
Try again from a different computer with a more recent git, as 1.7.1 is known to be problematic.  (At CMU, try Victor or usr/local/bin/git)
>
+
 
> ONE MORE THING.  Need to issue the pull request on the web page (for someone to approve the addition)
+
<pre style="color:darkblue">
>
+
git —-version
> Go to https://github.com/JeffersonLab/sim-recon and sign in on the RHS.
+
</pre><pre style="color:darkred">
> Below ‘Simulation and Reconstruction for GlueX’ there was a pale yellow box showing the name of my new branch, and on the RHS inside the box was
+
git version 2.5.0
> a green button ‘changes and pull request’.  Click it.
+
</pre>
>
+
<pre style="color:darkblue">
> Now wait for someone else to merge it. (or not).
+
git push origin cdcpluginupdate:cdcpluginupdate  
>
+
</pre><pre style="color:darkred">
 +
Counting objects: 7, done.
 +
Delta compression using up to 4 threads.
 +
Compressing objects: 100% (7/7), done.
 +
Writing objects: 100% (7/7), 1.43 KiB | 0 bytes/s, done.
 +
Total 7 (delta 6), reused 0 (delta 0)
 +
To https://github.com/JeffersonLab/sim-recon
 +
  * [new branch]      cdcpluginupdate -> cdcpluginupdate
 +
</pre>
 +
 
 +
ONE MORE THING.  Need to issue the pull request on the web page (for someone to approve the addition)
 +
 
 +
Go to https://github.com/JeffersonLab/sim-recon and sign in on the RHS.
 +
 
 +
Below ‘Simulation and Reconstruction for GlueX’ there was a pale yellow box showing the name of my new branch, and on the RHS inside the box was
 +
a green button ‘compare and pull request’.  Click it.
 +
 
 +
Now wait for someone else to merge it. (or not).
 +
 
 +
 
 +
 
 +
<h3>Other git things</h3>
 +
List tags: git tag -l<br/>
 +
Checkout tag: git checkout tagname<br/>
 +
Revert to tag called tagname: git reset --hard tagname<br/>
 +
<br/>
 +
Updating my local branch with changes in the remote master, eg to make my_branch consistent with tag 4.17.0:
 +
 
 +
<pre style="color:darkblue">
 +
git checkout master
 +
git pull
 +
git checkout 4.17.0
 +
git branch tag4.17.0
 +
 
 +
git checkout my_branch
 +
git merge tag4.17.0
 +
git commit
 +
</pre>
 +
I followed instructions to start up emacs and start the git server (M-x server-start, M is shift+command), typed a comment into the buffer, saved and exited emacs.

Latest revision as of 11:05, 1 March 2023

I needed to update one monitoring plugin file, which was in a non-git directory in my home area. This was the best way to go about it:

Make a local copy of the entire sim-recon repository for myself. This took about 5 seconds. OR... be sure to checkout the master branch and update it.

cd ~
mkdir git
cd git
git clone https://github.com/JeffersonLab/sim-recon

Check that the plugin in the repository is what I think it is

cd sim-recon/src/plugins/monitoring/CDC_online/
git status

Copy in my updated file

cp ~/online/plugins/CDC_online/JEventProcessor_CDC_online.cc .
git status
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   JEventProcessor_CDC_online.cc
#


List the changes between this copy and the original and make sure that they are all mine (use space to get to next page)

git diff


Make a new branch to contain and label my change

git branch cdcpluginupdate
git status
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   JEventProcessor_CDC_online.cc
#
no changes added to commit (use "git add" and/or "git commit -a")

Switch to the new branch, check the status and list the branches.

git checkout cdcpluginupdate
M	src/plugins/monitoring/CDC_online/JEventProcessor_CDC_online.cc
Switched to branch 'cdcpluginupdate'
git status
# On branch cdcpluginupdate
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	modified:   JEventProcessor_CDC_online.cc
#
git branch 
* cdcpluginupdate
  master

Add the file to the list of files to be committed/uploaded to the repository

git add JEventProcessor_CDC_online.cc

git status
# On branch cdcpluginupdate
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	modified:   JEventProcessor_CDC_online.cc
#

Commit change to the local repository

git commit -m "updated cdc_online for fa125 new format"

Send it to the remote repository. The first branchname given is the local name, the second is the new name on the remote repo (usually no need to change it).

git push origin cdcpluginupdate:cdcpluginupdate 

error: The requested URL returned error: 403 Forbidden while accessing https://github.com/JeffersonLab/sim-recon/info/refs fatal: HTTP request failed

This did not work, check the age of git

git —-version
git version 1.7.1

Try again from a different computer with a more recent git, as 1.7.1 is known to be problematic. (At CMU, try Victor or usr/local/bin/git)

git —-version

git version 2.5.0

git push origin cdcpluginupdate:cdcpluginupdate 

Counting objects: 7, done. Delta compression using up to 4 threads. Compressing objects: 100% (7/7), done. Writing objects: 100% (7/7), 1.43 KiB | 0 bytes/s, done. Total 7 (delta 6), reused 0 (delta 0) To https://github.com/JeffersonLab/sim-recon

* [new branch]      cdcpluginupdate -> cdcpluginupdate

ONE MORE THING. Need to issue the pull request on the web page (for someone to approve the addition)

Go to https://github.com/JeffersonLab/sim-recon and sign in on the RHS.

Below ‘Simulation and Reconstruction for GlueX’ there was a pale yellow box showing the name of my new branch, and on the RHS inside the box was a green button ‘compare and pull request’. Click it.

Now wait for someone else to merge it. (or not).


Other git things

List tags: git tag -l
Checkout tag: git checkout tagname
Revert to tag called tagname: git reset --hard tagname

Updating my local branch with changes in the remote master, eg to make my_branch consistent with tag 4.17.0:

git checkout master
git pull
git checkout 4.17.0
git branch tag4.17.0

git checkout my_branch
git merge tag4.17.0
git commit

I followed instructions to start up emacs and start the git server (M-x server-start, M is shift+command), typed a comment into the buffer, saved and exited emacs.