git on davidchua https://dchua.com/tags/git/ Recent content in git on davidchua Hugo -- gohugo.io en-us Sat, 03 Jan 2015 00:00:00 +0000 Ignore files already committed to Git https://dchua.com/posts/2015-01-03-ignore-files-already-committed-to-git/ Sat, 03 Jan 2015 00:00:00 +0000 https://dchua.com/posts/2015-01-03-ignore-files-already-committed-to-git/ Have you ever have a situation where you do not want your changes to a particular file to be tracked but you still need it in the repository for future developers? An example of this would be the new config/secrets.yml in Rails 4.x secrets.yml acts as a replacement for .env files but unlike .env files, you need secrets.yml in your repository in order not to break your app. With secrets.yml already committed into your application by default, how do you untrack future changes to it? Git pull request for Git https://dchua.com/posts/2013-08-01-git-pull-request-for-git/ Thu, 01 Aug 2013 00:00:00 +0000 https://dchua.com/posts/2013-08-01-git-pull-request-for-git/ One of the nice features of a forking workflow is that your repository is always clean and you can pick and choose features from other forked developers' repository to merge with yours. When we usually think ‘fork’ and ‘git’, I’m sure to most of us, Github’s forking/pulling workflow comes in mind. But did you know you can actually do a git-pull-request on a non-github repository and also on a centralized feature branch workflow? Unstage your last git commit - Temporary commits for workstation switches https://dchua.com/posts/2013-07-31-unstage-your-last-git-commit-temporary-commits-for-workstation-switches/ Wed, 31 Jul 2013 00:00:00 +0000 https://dchua.com/posts/2013-07-31-unstage-your-last-git-commit-temporary-commits-for-workstation-switches/ Undo a git commit. Sometimes when I’m switching between workstations while working halfway onto code, I’d need to find a way to transfer WIP code over. There are a couple of ways to do this. Some would create patches, copy it into dropbox, and pull and apply it on the new workstation. For me, I would just create a new branch, commit the changes as “WIP”, push it to the remote repository and pull the whole branch over from the other workstation. Git commit individual line changes / View staged changes' diff https://dchua.com/posts/2013-06-30-git-commit-individual-line-changes-view-staged-changes-diff/ Sun, 30 Jun 2013 00:00:00 +0000 https://dchua.com/posts/2013-06-30-git-commit-individual-line-changes-view-staged-changes-diff/ When working on files where you want to commit specific line changes into separate commits, there is a way to individually select lines of the changes that you want to commit. Use: git add -p Git diff on its own lets you view changes between your HEAD and the current unstaged state. To view changes of staged changes (but not committed), use: git diff --cached In order to save time, in my personal ~/. Using Amazon S3 as your private git repository https://dchua.com/posts/2012-01-12-using-amazon-s3-as-your-private-git-repository/ Thu, 12 Jan 2012 00:00:00 +0000 https://dchua.com/posts/2012-01-12-using-amazon-s3-as-your-private-git-repository/ Been trying to move my git repositories and apps from my old (and expensive) VPS into Amazon’s EC2 when I asked myself whether it is possible to push use Amazon S3 as a git repository. Some searching later, I found out the answer. YES! It is not only possible to push your repositories into your S3 bucket, but its also possible to do so even when your bucket is in a non-US region. Linus Torvalds: Please write good git commit messages https://dchua.com/posts/2011-11-28-linus-torvalds-please-write-good-git-commit-messages/ Mon, 28 Nov 2011 00:00:00 +0000 https://dchua.com/posts/2011-11-28-linus-torvalds-please-write-good-git-commit-messages/ That’s right. Header line: explaining the commit in one line Body of commit message is a few lines of text, explaining things in more detail, possibly giving some background about the issue being fixed, etc etc. The body of the commit message can be several paragraphs, and please do proper word-wrap and keep columns shorter than about 74 characters or so. That way “git log” will show things nicely even when it’s indented. Getting your git repository to send out e-mails upon receiving updates https://dchua.com/posts/2010-04-29-getting-your-git-repository-to-send-out-e-mails-upon-receiving-updates/ Thu, 29 Apr 2010 00:00:00 +0000 https://dchua.com/posts/2010-04-29-getting-your-git-repository-to-send-out-e-mails-upon-receiving-updates/ Here’s a useful tip for those who wants to be updated everytime someone pushes code into a shared git repository. There’s a hook that comes with git that sends out an email to a defined e-mail address with information about a commit that has recently been pushed. It tracks the author, the commit message, the commit log as well as displays the changes made. Lets get started. Prepare your remote git repository In your remote server where your remote git repository resides, you should find the following file in remote_repository_path/.