Installing/Using Git Version/Revision/Source Control System on local network

Installing/Using Git Version/Revision/Source Control System on local network:

You can install the Git Windows portable 7z autounzip file and add environment variable for gitdir and add your gitdir\cmd\ to your path, or you can install the Git Windows exe for full Windows GUI install.

For a client GUI you can install the EGit plugin for Eclipse or the TortoiseGit msi file for integration with Windows Explorer.

With TortoiseGit you can skip the add file and just commit new files directly.  You can also push changes to the central repository at the same time that you do a commit.

Our network central git repository: \\SERVER3\DevelopmentDocs\gitRepository

A Git repository is only a directory on our file system with a .git directory inside of it.  Creators and users are equal users (in our read/write gitRepository permissions group) who have Git installed so they can access them with Git tools.  The repositories location is on a regular backup schedule in case of an accident.  The distributed user repositories helps, too.

You can access it by mapping the network to a drive letter or use the network url:

\\SERVER3\DevelopmentDocs\gitRepository\utility\.git

file://///SERVER3\DevelopmentDocs\gitRepository\utility\.git

I created my app in a utility directory on my D: drive and git puts a .git file in that directory:

git init

git add .

git commit

I went to the destination network central git repository and used this command to create a new repository in a new utility directory below the current directory:  git clone file:///D:/eclipse-projects/azgs2/utility/.git

There is a throwaway gittest repository in the central repository area for you to experiment on (or create your own additional testing repositories).  Feel free to add, delete, modify, and move changes between repositories and your working directory trees to see if Git can do everything you might need.

Problems:

To allow users to push changes to this particular central repository, go to the central repository directory and run: git config receive.denyCurrentBranch ignore

If you need to see the new files in the network common repository to be sure it was done (common repository working tree is not used) do a hard reset or possibly just a checkout: git checkout or git reset --hard

The EGit plugin for Eclipse is shaky on ignoring files in your working directory that you don't want included in the repository.  If you need to remove and sometimes add files, you can edit the .gitignore file directly (with files separated by a "/")

More Git commandline commands:

More Git command details: http://refcardz.dzone.com/refcardz/getting-started-git

Commands working with a 2nd repository transparently are using the origin (original source repository cloned from).  Use a specific file:/// url for any 3rd same kind repository accessed, like for push or pull.

Create an initial Git repository in current directory: git init

Add a new file to working directory tree/index before commit: git add myfile.txt

Add all files to working directory tree/index before commit: git add .

Create a local copy of remote Git project in new subdirectory utility and name source as origin: git clone file:///D:/eclipse-projects/azgs2/utility/.git

Delete a file: git rm myfile.txt

Tell Git to track same file in new location/name: git mv file.txt dirname/newname.txt

Apply changes in existing repository files in working directory tree to local repository: git commit

Undo last local commit: git commit --amend

Safely undo last commit that will be moved to shared repository (new commit added at end): git revert HEAD

Safely undo next to last commit that will be moved to shared repository (new commit added at end): git revert HEAD^

May tell you if  there is a problem with the repository or working directory: git status

Pull origin respository into local copy as branch: git fetch

Pull specific repository into local copy as branch: git fetch file://///SERVER3\DevelopmentDocs\gitRepository\utility\.git

Compare local repository with fetched origin repository for differences: git diff master origin/master

Actually merge local copy of remote branch with local repository (loses individual local commit history): git merge origin/master

Pull specific repository into local repository and apply local commits with full local commit history retained: git rebase origin

Undo rebase to local repository: git rebase --abort

Fetch and merge to update local repository and working directory: git pull

Fetch and merge from specific 3rd repository (not origin): git pull file://///SERVER3\DevelopmentDocs\gitRepository\utility\.git

Supposed to update working directory from local repository: git checkout

Update working directory from local repository to next to last commit: git reset --hard HEAD^

Update central repository (or any specific repository) with your local repository: git push file://///SERVER3\DevelopmentDocs\gitRepository\utility\.git master

Check the current configuration in this repository: git config -l

Save all working tree changes to stack and restore working tree to last commit: git stash

Restore working tree back to state before stash: git stash pop

List all local and remote branches git branch -a:

Display addresses of remote repositoriesgit remote -v:

Label for history/retrieval puposes such as version/release: git tag tagname

 

Create local Git repository from SVN remote url: git svn clone --stdlayout svnrepositoryurl

Push local repository changes back to original SVN: git svn dcommit

Pull latest changes from original SVN: git svn rebase