Editing
Setting Up a Remote GIT Repository on Windows Server
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!
[[Category:How-To's]] [[Category:Git]] [[Category:Web Development]] == Overview == <p class="alert alert-warning">Using GitHub instead for now. Most of the information in this article is outdated, or irrelevant.</p> I’m not sure if this will ultimately be something that I will use, but I’m thinking of moving away from Perforce and using Git instead. The description of using Git to apply patches makes a whole lot more sense now that I’m using these shared libraries for all of the PHP sites. === references === *[http://gitref.org/ GIT Reference] *[http://schacon.github.com/git/gittutorial.html Git Tutorial] *[http://schacon.github.com/git/user-manual.html Git User's Manual] * [http://help.github.com/git-cheat-sheets/ Git Cheat Sheet] *[http://help.github.com/win-set-up-git/ Guide for setting up Git on Windows] *[http://holyhoehle.wordpress.com/tag/winsshd/ Setting up a Git server on a Windows server] (Copy saved on [http://littledamien.com/articles/details.php?id=647 littledamien.com]) *[http://nathanj.github.com/gitguide/tour.html Illustrated Guide to Git on Windows] *There are useful articles on GIT on [http://haacked.com/tags/git/default.aspx this blog], e.g. [http://haacked.com/archive/2011/12/13/better-git-with-powershell.aspx Better Git with PowerShell] *[https://github.com/dahlbyk/posh-git Posh-Git] prompt enhancement for Git on Windows PowerShell *Rails installer for Windows: http://rubyforge.org/frs/?group_id=5288&release_id=46336 *Ruby tutorial: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book ==Setting up Git, from the [http://ruby.railstutorial.org/ruby-on-rails-tutorial-book#sec:version_control Ruby on Rails tutorial]== ===First time system setup=== Setting your identity locally: <syntaxhighlight lang="bash"> $ git config --global user.name "Your Name" $ git config --global user.email youremail@example.com </syntaxhighlight> Set up command aliases (in this case “git co” becomes an alias for “git checkout”): <syntaxhighlight lang="bash"> $ git config --global alias.co checkout </syntaxhighlight> Set the editor for Git commit messages, making sure to use a flag so the editor stays attached to hte shell: <syntaxhighlight lang="bash"> $ git config --global core.editor "mate -w" </syntaxhighlight> ===First-time repository setup=== Navigate to the root directory of the repository. <syntaxhighlight lang="bash"> $ git init Initialized empty Git repository in /Users/mhartl/rails_projects/first_app/.git/ </syntaxhighlight> Add the project files to the repository. Create a <code>.gitignore</code> file, which will specify all the files that should not be tracked by Git. (With Rails apps, Rails creates a skeleton <code>.gitignore</code> automatically.) Add all the files in the current directory to Git <syntaxhighlight lang="bash"> $ git add . </syntaxhighlight> This command adds the project files to a ''staging area'', which contains pending changes to the project. To see which files are in this staging area, use the <code>status</code> command: <syntaxhighlight lang="bash"> $ git status # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: README # new file: Rakefile . . . </syntaxhighlight> ==Editing, Working with GIT== Commit changes (locally) with <syntaxhighlight lang="bash"> $ git commit -m "Initial commit" [master (root-commit) df0a62f] Initial commit 42 files changed, 8461 insertions(+), 0 deletions(-) create mode 100644 README create mode 100644 Rakefile . . . </syntaxhighlight> The <code>-m</code> flag allows you to add a comment; if you omit <code>-m</code>, Git will open the commit editor and you will have to enter your comment there. Git is unique in that it divides commit into two logical steps: a local recording of the changes (<code>git commit</code>) and a push of hte changes up to a remote repository (<code>git push</code>). To see a list of commit messages, use the <code>log</code> command. Type q to break out of the <code>git log</code> if it is long. <syntaxhighlight lang="bash"> $ git log commit df0a62f3f091e53ffa799309b3e32c27b0b38eb4 Author: Michael Hartl <michael@michaelhartl.com> Date: Thu Oct 15 11:36:21 2009 -0700 Initial commit </syntaxhighlight> Push code to remote Git repository (GitHub, for example). Create a new repository on the remote server. Push the application to the remote repo: <syntaxhighlight lang="bash"> $ git remote add origin git@github.com:<username>/first_app.git $ git push origin master </syntaxhighlight> These commands tell Git that you wnt to add GitHub as the origin for your main (master) branch and then push your repository up to GitHub.
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