https://dune.bnl.gov/w/index.php?title=Git&feed=atom&action=historyGit - Revision history2024-03-29T07:20:06ZRevision history for this page on the wikiMediaWiki 1.34.4https://dune.bnl.gov/w/index.php?title=Git&diff=2379&oldid=prevMaximPotekhin: Created page with "=Starting out= Notify git of your identity and ID: <pre> git config --global user.email "yourname@yoursite.yourdomain" git config --global user.name yourID </pre> To avoid e..."2019-03-27T21:48:51Z<p>Created page with "=Starting out= Notify git of your identity and ID: <pre> git config --global user.email "yourname@yoursite.yourdomain" git config --global user.name yourID </pre> To avoid e..."</p>
<p><b>New page</b></p><div>=Starting out=<br />
Notify git of your identity and ID:<br />
<pre><br />
git config --global user.email "yourname@yoursite.yourdomain"<br />
git config --global user.name yourID<br />
<br />
</pre><br />
<br />
To avoid entering git userID and password:<br />
<pre>git config --global credential.helper 'cache --timeout 7200'</pre><br />
<br />
To address the usual "^M" problem when switching between Linux and Windows environments<br />
<pre><br />
$ git config --global core.autocrlf true<br />
# Remove everything from the index<br />
$ git rm --cached -r .<br />
<br />
# Re-add all the deleted files to the index<br />
# You should get lots of messages like: "warning: CRLF will be replaced by LF in <file>."<br />
$ git diff --cached --name-only -z | xargs -0 git add<br />
<br />
# Commit<br />
$ git commit -m "Fix CRLF"<br />
</pre><br />
<br />
(Also see https://stackoverflow.com/questions/1889559/git-diff-to-ignore-m)<br />
<br />
=Restoring Files=<br />
First, see this link:<br />
<br />
https://stackoverflow.com/questions/953481/find-and-restore-a-deleted-file-in-a-git-repository<br />
<br />
A recipe that may work well:<br />
<pre><br />
git log --diff-filter=D --summary # finds deleted files<br />
git checkout $commit~1 filename # where "$commit" stands for the actual commit name (a long string)<br />
</pre><br />
In the above, it's best to operate from the top level directory of the project and use path relative to that.<br />
Also, you may want to "git add" the restored files and commit them to make it permanent.<br />
<br />
If you want to get a specific previous revision of a file, just capture the stdout of the following command:<br />
<pre><br />
git show $REV:$FILE<br />
</pre><br />
...and rename the output as you see fit.<br />
<br />
=Undoing a commit=<br />
See:<br />
<br />
https://sethrobertson.github.io/GitFixUm/fixup.html<br />
<br />
If you want to reverse your latest commit to the HEAD:<br />
<pre><br />
git reset --hard HEAD<br />
</pre><br />
<br />
To remove two last commits:<br />
<pre><br />
git reset --hard HEAD~2<br />
</pre><br />
<br />
<br />
=gitHub quirks =<br />
Sometimes a cloned repo will end up in a state where you can't push local content. Things you might want to try:<br />
<pre><br />
git remote set-url origin https://buddhasystem@github.com/DUNE/dqmconfig.git<br />
</pre><br />
<br />
And in case it was not annoying enough, if you see something like "can't open display"<br />
this may help:<br />
<pre><br />
unset SSH_ASKPASS<br />
</pre></div>MaximPotekhin