Git
Contents
Git Docs
Install
Git for the first time
Setting up Git for the first time
Git Ignore File
create a file called .gitignore_global in you home directory
# OS generated files # ###################### .DS_Store* ehthumbs.db Icon? Thumbs.db ._* *.swp # Gaslight Media Application specific # # files that are updated on server # ####################################### iconCache/ uploads/ cache/ compiled/ compile/ original/ resized/ midsized/ thumb/ thumbs/ ht_images/ photo-large/ photo-small/ prototype/ weather-feed.xml php.error reports/ editimagesworkwith/ editimagesoriginal/ editedImages/ editimagespng/ .buildpath .settings .project .svn nbproject
SSH Keys
Creating your ssh keys (private/public)
Git-Svn
Checking out a site from svn with git (limit git) git svn http://git-scm.com/book/ch8-1.html
Gitolite
gpg signing
How to sign your commit or tags
Reference
git book online http://git-scm.com/book
Git Flow Process (example)
This is merely an example. Things may not always follow this line of commands exactly.
(0. ssh-add)
1. git clone git@cvs2:web/mywebsite.git www.mywebsite.com (like SVN checkout)
2. cd www.mywebsite.com
3. git flow init (master, develop, feature, release, hotfix, support, V (only change from default) - this should only be necessary -once- the very first time anyone sets up the repository for the website)
4. git branch -av (shows what branch you are on, as well as the branches that exist both locally and remotely)
5. git checkout develop (unnecessary, but UNLIKE SVN this merely changes the branch you're currently on to Develop)
6. git flow hotfix start 1.0.3 (this creates the hotfix branch called 1.0.3)
(*. or: git flow feature start AwesomeFeature)
-- start up your favorite editor and make whatever changes to whichever project/files you please --
7. git status (will show you all changed files)
8. git add . (will make all files in all folders in the current directory ready for committing)
(*. or to add a single file: git add .htaccess)
9. git commit (will commit changes to the main branch)
(*. oops! Forgot a change/file? It's not too late to add: git commit --amend )
10. liberal use of git status. This will also show the command git reset HEAD -- .gitignore.whatever to remove something you git add-ed (also works on folders)
11. git flow hotfix finish '1.0.3' (this will bring you back to the develop branch and delete the hotfix branch after it merges its changes. Make note of your edits!)
(*. git flow feature publish someFeature is another example, though publish doesn't remove the branch, it merely does the merge)
(*. Git may at some point complain about the fact that there are changes to wherever you're trying to commit/push to. It's merely a matter of doing git pull origin develop (where origin is the name of the branch you're taking it from, and develop is the branch you're taking it to) so that you're up-to-date!)
(*. git pull is a two-step process: git fetch takes it from the main repository onto your remotes branch, then git merge takes it from there to whatever branch you indicated (where you're likely working from)
(*. This is also when you may realize you didn't yet start a branch, and you've already made changes. Have a look at git stash, which will essentially put all changes into a separate stash. Then git flow feature start awesomeFeature, which should put you on that branch, then do git stash pop to drop the stash onto that branch, after which the branch can be finished or published as noted above)
10. git branch -av (to make sure you're on the branch you're meant to be)
11. git push origin develop (send changes to the remote main branch - TO origin FROM develop)
(*. git push --all is an alternative though it may be safer to be precise. This must be followed by git push --tags)
12. gitk to marvel at a graphical representation of the good you've done today
13. ssh ws6 (or dev53 or whatever server), then cd /var/www/server/www.myweb~
14. git pull origin develop (this command may also be used on your own server kind of like svn checkout, instead of cloning at step 1)
(*. on WS6 you use git pull origin master instead, since it only has a master branch)