Editing
Git Workflow
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Overview== Git Server set up on dbarchowsky.com. [http://netbeans.org/kb/docs/ide/git.html NetBeans Git User Guide] ==Working with existing projects== * Make sure the 'dev' drive is available on the current client. See [[#Configuration|Configuration]] Using 'Git Bash' navigate to the project directory. <syntaxhighlight lang="bash"> $ cd /m/littledamien/littledamien_web </syntaxhighlight> * To see a list of previous commits (which should include the branch names as part of the commit message): <syntaxhighlight lang="bash"> $ git log --oneline </syntaxhighlight> * Make a new Git branch : Naming convention: 'tm' + sequential number <syntaxhighlight lang="bash"> $ git co -b mynewbranch </syntaxhighlight> * Edit as necessary. Then verify changed files with <syntaxhighlight lang="bash"> $ git status -s </syntaxhighlight> * Add edits to commit with <syntaxhighlight lang="bash"> $ git add filename.ext </syntaxhighlight> * Stage a deleted file with <syntaxhighlight lang="bash"> $ git add -u filename.ext </syntaxhighlight> * Revert files with <syntaxhighlight lang="bash"> $ git co HEAD filename.ext </syntaxhighlight> * Verify edits with <syntaxhighlight lang="bash"> $ git diff --cached $ git diff --cached filename.ext </syntaxhighlight> * Commit the edits ('tm0001' being the branch name used to track projects) <syntaxhighlight lang="bash"> # commit all edits $ git commit -m "tm0001: commit message" # switch to master branch $ git co master # merge edits into master branch $ git merge tm0001 # clean up branch $ git branch -d tm0001 </syntaxhighlight> * Then move the commits to the main repo: <syntaxhighlight lang="bash"> $ cd /n/git/littledamien/littledamien_web $ git pull /m/littledamien/littledamien_web $ # or $ git push ssh://[uname]@[domain].com:[port]/refs/littledamien/littledamien_web $ # or $ git push ssh://[uname]@[domain].com:[port]/refs/littledamien/littledamien_web master $ # or (after creating an alias in .ssh/config) $ git push dbarchowsky:/refs/littledamien/littledamien_web </syntaxhighlight> ==Deploying updates== ===SFTP client=== * WS_FTPro with SFTP ===Netbeans=== # Configure project to link it to SFTP connection. ## Right click on project > Properties ## Run Configuration > Remote Connection ## Run As: Remote Web Site (FTP, SFTP) ## Select existing connection, or make a new one. ::* Host Name, Port Name, User Name, Password: self-evident ::* Private Key File: [leave blank] ::* Known Hosts File: ~/.ssh/known_hosts ::* Initial Directory: /path/to/web_root # Select files within Netbeans project tree, right click > Upload ==Creating a new repo out of an existing site== ===Creating the Git repos=== * Navigate to the site's root directory. * Create a Git repository. <syntaxhighlight lang="bash"> $ git init </syntaxhighlight> * Make a .gitignore file (images, wordpress install files, etc.) : Copy from an existing web project and modify as necessary. * Set username and email (necessary for each repo) <syntaxhighlight lang="bash"> $ git config --global user.name "Damien Barchowsky" $ git config --global user.email "dbarchowsky@gmail.com" </syntaxhighlight> * Add existing files to Git repo, confirm the list of files, and commit the changes. <syntaxhighlight lang="bash"> $ git add . $ git status -s $ git commit -m "Initial version" </syntaxhighlight> * Clone the repo to 'origin' <syntaxhighlight lang="bash"> $ cd /n/git/base_dir $ git clone /m/base_dir/repo_dir </syntaxhighlight> ===Configure SSH to allow Git to push to the production server with non-standard port number=== * [http://stackoverflow.com/questions/1558719/using-a-remote-repository-with-non-standard-port Stackoverflow: Using a remote repository with non-standard port] * Edit <code>.ssh/config</code> <syntaxhighlight lang="text"> Host sitealias HostName domainname.com Port 12345 User siteuser </syntaxhighlight> * then you should be able to use the basic syntax: <syntaxhighlight lang="text"> git push sitealias:/path/to/public_html master </syntaxhighlight> ===Deploy a project using Git push=== '''Note:''' this is not available with shared hosting. Changes must be uploaded with FTP. Refer to [http://community.namecheap.com/forums/viewtopic.php?f=7&t=4275 this thread on the NameCheap forums]. [http://stackoverflow.com/questions/279169/deploy-a-project-using-git-push Stackoverflow: Deploy a project using Git push] 1. Copy over your <code>.git</code> directory to your web server : Make sure to disallow access to any files within the <code>.git</code> directory! : Put an <code>.htaccess</code> file in the <code>.git</code> directory with :<syntaxhighlight lang="text"> deny from all </syntaxhighlight> 2. On your local copy, modify your .git/config file and add your web server as a remote: <syntaxhighlight lang="text"> [remote "production"] url = username@webserver:/path/to/htdocs/.git </syntaxhighlight> 3. On the server, replace .git/hooks/post-update with [http://littled.dbarchowsky.com/wiki/upload/post-update this file] 4. Add execute access to the file (again, on the server): <syntaxhighlight lang="bash"> chmod +x .git/hooks/post-update </syntaxhighlight> 5. Now, just locally push to your web server and it should automatically update the working copy: <syntaxhighlight lang="bash"> git push production </syntaxhighlight> ==Configuration== ===Showing git settings=== Show all <syntaxhighlight lang="bash"> $ git config --list </syntaxhighlight> Show a specific setting <syntaxhighlight lang="bash"> $ git config user.name </syntaxhighlight> ==='littledamienii' repo setup=== * Make sure the 'dev' drive is available while working with Git Bash on the current client. <syntaxhighlight lang="dos"> subst m: "\\littledamienii\develop" subst n: "\\littledamienii\shared" </syntaxhighlight> * Physical origin repos located beneath <code>d:\shared\git</code> * To make a new project: <syntaxhighlight lang="dos"> d: cd \shared\git git clone ..\..\develop\path\to\project_root cd .\path\to\project_root git init rem <<< is that last 'git init' step necessary ??? >>> </syntaxhighlight> * At least for now, when fetching & pulling vial ssh, the root directory is the Git install directory (<code>C:\Git</code>). :* A symbolic link has been created between <code>C:\Git</code> directory and the Git base directory (<code>D:\shared\git</code>) <syntaxhighlight lang="dos"> cd \Git mklink /d "refs" "d:\shared\git" rem symbolic link created for refs <<===>> d:\shared\git </syntaxhighlight> :* The symbolic link allows access to the git repo via <syntaxhighlight lang="dos"> git clone|push|pull|etc. ssh://username@server/refs/path/to/myrepo </syntaxhighlight> [[Category:Git]] [[Category:Web Development]]
Summary:
Please note that all contributions to Littledamien Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Littledamien Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information