git – Adams Bros Blog http://blog.adamsbros.org Wed, 15 May 2019 01:44:20 +0000 en-US hourly 1 https://wordpress.org/?v=5.2.2 git text graph http://blog.adamsbros.org/2015/09/08/git-text-graph/ http://blog.adamsbros.org/2015/09/08/git-text-graph/#respond Tue, 08 Sep 2015 15:46:39 +0000 http://blog.adamsbros.org/?p=599 I’ve been looking for a really good command for making a textual graph of my repo, showing the various branches, where they come from, etc. The reason I like this one is that it’s not only a graph, but it shows the branch names like ‘gitk –all’ does, but only the ones that are tied to tags or branches.

git config --global alias.graph \
'log --graph --pretty=oneline --abbrev-commit --simplify-by-decoration --decorate --all'
git graph
]]>
http://blog.adamsbros.org/2015/09/08/git-text-graph/feed/ 0
Git Recover Deleted or Staged Files http://blog.adamsbros.org/2015/02/09/git-recover-deleted-or-staged-files/ http://blog.adamsbros.org/2015/02/09/git-recover-deleted-or-staged-files/#respond Mon, 09 Feb 2015 21:23:36 +0000 http://blog.adamsbros.org/?p=565 I ran into a situation where I accidentally staged a file I didn’t want to stage, and when I ran “git reset –hard” it was wiped out. After a simple google search (git recover staged files), recovering the file was simple.  I’ve put together a loop, which will check each commit, and look for a string “responsive”, which I know is in the file.

git fsck --lost-found | cut -f 3 -d ' ' | \
  while read -r commit; do 
    git show $commit | grep responsive; 
    if [ $? -eq 0 ]; then 
      echo $commit; 
    fi; 
  done

The response was…

rm -rf web/src/main/webapp/responsive/.sass-cache/
53fcd5f117f8e19243dfcde24c14524dc99b4c1e

I then just showed the commit blob with…

git show 53fcd5f117f8e19243dfcde24c14524dc99b4c1e
#!/bin/bash

cp -r /media/mount/* web/src/main/webapp/
rm -rf web/src/main/webapp/lost+found/
rm -rf web/src/main/webapp/responsive/.sass-cache/
find web/ -name '._*' | while read -r filename; do 
 rm -f "$filename"
done
rm -rf web/src/main/webapp/META-INF/
git status
]]>
http://blog.adamsbros.org/2015/02/09/git-recover-deleted-or-staged-files/feed/ 0
Git Setup with SSH http://blog.adamsbros.org/2014/11/11/git-setup-with-ssh/ http://blog.adamsbros.org/2014/11/11/git-setup-with-ssh/#respond Tue, 11 Nov 2014 19:46:39 +0000 http://blog.adamsbros.org/?p=510 This is just a simple rundown of how to setup git properly for SSH use. SSH specific information about how to connect using SSH keys, and things of that nature, are not within the scope of this post. I will update this as I go.

1. To ensure that you are creating repositories with the correct permissions, you need to set the git config variable core.sharedRepository on the server.  You need the –system, so that it gets stored in /etc/gitconfig.

 git config --system core.sharedRepository group

2. Setup your git commit notification.

After that, it’s just a matter of chowning your repo to the correct group on the server.  If you didn’t originally create your repos with proper group permissions, you’re going to have to do that.

chown -R :group /home/git/myrepo
find /home/git/ -type d | while read -r dir; do chmod g+s "$dir"; done
find /home/git/ -type f | while read -r file; do chmod g+rw "$file"; done
]]>
http://blog.adamsbros.org/2014/11/11/git-setup-with-ssh/feed/ 0
git Commit Email Notification http://blog.adamsbros.org/2014/11/11/git-commit-email-notification/ http://blog.adamsbros.org/2014/11/11/git-commit-email-notification/#respond Tue, 11 Nov 2014 10:37:22 +0000 http://blog.adamsbros.org/?p=506 I couldn’t really find anything that could get me up and running really quickly with git commit emails. In this blog post we provide a git post-receive-email example.  In our case, our server is CentOS.

  1. modify the “description” file on the server in the root of the git repo, so that your project can have a name, and the email subject lines will have that name.
  2. setup the post receive configuration in /etc/gitconfig
  3. In the hooks directory on the server, copy the post-receive.sample to post-receive, and uncomment the post-receive-email script

If in the root of the git repo, issue the following commands to do the above.

 echo "Project Name" > description
cat > hooks/post-receive <
# show the diff of the commit
git config hooks.showrev "git show -C %s; echo"

Note that the git config command above will change the "config" file in that repo to have a proper email destination.

]]> http://blog.adamsbros.org/2014/11/11/git-commit-email-notification/feed/ 0