Thursday, December 13, 2012

GIT for beginners (and me)

Starting working with GIT ( I'm currently using SVN and I used in the past ClearCase rip) .
Here are some useful commands :

  • git init    - for initializing the .git/  repository in your current directory
  • git status -  return which files should be committed etc ...
  • git add  - mark files for the repository , so you remember to commit them later on. Those file will become candidate for commit
  • git add \*.java  - will add recursively ALL the java files 
  • git commit -m "My comment about this commit"  - obvious
  • git branch -b BranchName  - switch to the BranchName branch
  • git checkout -b NewBranchName  - copy your current branch into another NewBranchName
  • git branch - show all your defined branches and indicate what is your current branch
  • git reset --hard HEAD  - revert to the HEAD version, overwirting any local change (hard)
  • git merge show_michael  (didn't use it yet)
Here are some good links (as it seems to me now that some bullet in my summary are incorrect)


Another tutorial suggested to me today :
http://pcottle.github.io/learnGitBranching/

And some interesting procedure for working with SVN while working with git:


git stash list  
git stash drop     <<== Delete stash
git stash list  
git status
git stash       <<== save in a stash backup all the dirty files (the one that were not committed. but not the ones which are not yet added only to git )
git stash list
git status
git checkout master   <<== go to master , when your current branch is clean (no stash anymore)
svn update    <<= update with SVN
git status
git add .       <<= this is the quick way to get it all your svn update to your git
git status
git commit -m "svn update"  
git status
git checkout oauth  <<== return back to your working branch 
git status
git merge master oauth  <<== merge, for getting all the SVN update (but using git now)
git status
git stash apply  <<== retrieve the stash dirty files ... 
git status
history