Pages

Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

17 Apr 2013

Some useful GIT commands

View unpushed commits
git log --branches --not --remotes

Make git command line colorful
git config --global --add color.ui true 

17 Nov 2012

A note about .gitignore

First of all, take a look at this page: http://gitready.com/beginner/2009/01/19/ignoring-files.html
And I'm not copying its content lol, well, this is just a note about what I've done successfully with .gitignore to ignore some folders in my project.

Steps:
  • Enter to root directory of your project, then "vi .gitignore" and enter something like:(I suppose you haven't had .gitignore in your project):
  • bin/ # ignore all folders which are named "bin"
    .settings/ # ignore all folders which are named ".settings" 

  • If there's nothing in your "bin" folders as well as ".settings" folders, your job here is done, everything you will put in those folders will not be tracked by Git. But if there's something in those folders which means Git are tracking it already, so you have to let Git know that you don't want to tracking it by these commands:
  • git rm --cached -r Your_Path/bin/
    git rm --cached -r Your_Path/.settings/
    git commit -m "Ignore folder bin and .settings"
    git push origin your_branch
    

P/S: You may doubt about removing cache then commit & push, and yeah, I did, but don't worry. Doing so just removes cache not actual files in your folders (actually I have no idea about where is cache too, but I guess it's cache of git lol), and committing & pushing just delete those folders on remote server, not on your local repository.
In short, making a ".gitignore" just tells your Git program on your computer knows that don't list changes of files in those folders when you type "git status",  and removing cache & committing & pushing just delete those folders on remote repository.

How to install and config Smartgit + Git + Bitbucket.org

  • Download install Git: http://git-scm.com/downloads
  • Download install SmartGit: http://www.syntevo.com/smartgit/download.html
  • Add SSH public key:
    • Generate SSH public key if it hasn't been created
      • Open Git Bash -> Generate SSH public key by typing: ssh-keygen -t rsa -C "your_email@youremail.com" -> Public key will be located in folder "~/.ssh/"
    •  Add SSH public key to bitbucket.org
      • Open bitbucket.org -> Account setting -> SSH keys -> Add Key -> Add content of "~/.ssh/id_rsa.pub" as a key
  • In order to be able to push, you have to config your name and email, open Git Bash, type:
    • git config --global user.email "abcd@xyzt.com"
    • git config --global user.name "Blah Bloh"
  • Clone a project (choose SSH, don't choose HTTPS, otherwise you will not be able to push properly by SmartGit - Actually, I don't know why, it took me a few hours to realize that, but I still can't explain why now lol):
    • git clone git@bitbucket.org:user_name/project_name.git
  • Add project to Smartgit:
    • Project -> Open Repository -> Choose your project folder -> Next...