In GIT you can have multiple repositories.
A classical example is 1 remote repository, to which all the developers push.
Every developer also has a local repository. This is usually in the working directory.

To know the remote repositories:
git remote -v
This will show the name and url of the remote repositories. The default name of a remote repository is origin.

Git clients
- Git GUI (comes default with GIT)
- Tortoise Git
- Smart Git
- Source Tree
- GitKraken
- Visual Studio

Git workflows

GitHub Flow
Too simple. Just check pull request.
GitLab Flow

Convert a SVN repository to Git

Convert the repository

If the you have a local SVN repository, you need to expose it by the svn: protocol. You can do this with svnserve:

svnserve.exe -d -r pathToMyLocalSvnRepositories

By default, the username of SVN will be taken. This means it won't have an email. In Git, a user normally has an email.
So if you push to a server like eg. VSTS, this system will create a virtual email address for you.
If you want to manage the users for Git, you first need to extract the SVN users, first extract all the users of the commits.
Execute next line in Git Bash:
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt
The users will now be in the authors-transform.txt file like name = name <name>
Edit this file so you have the descriptions you want like name = full name <moc.liam|eman#moc.liam|eman>

Then clone the svn repository to Git:
Without authors file:

git svn clone svn://localhost/myLocalSvnRepository --no-metadata --stdlayout pathToMyNewGitRepository

With authors file:
git svn clone svn://localhost/myLocalSvnRepository --no-metadata -A authors-transform.txt --stdlayout pathToMyNewGitRepository

If you only want to have the trunk:
git svn clone svn://localhost/myLocalSvnRepository/trunk --no-metadata -A authors-transform.txt pathToMyNewGitRepository

The tag —stdlayout means you have a classical SVN setup with tags, branches and trunk folders. It is possible to change this by adding

--trunk=Trunk --tags=Tags --branches=Branches

Normally, the SVN trunk will be renamed to the Git master.
If this was not the case, you can do it manually with:

git branch -m trunk master

Push to your remote repository

For creating a bare remote repository in VSTS, see Varia - Visual Studio Team Services.

git remote add origin https://{account}{name repository}
git push -u origin --all

I noticed in this way the tags aren't shown in VSTS.
Maybe you need to do also
git push origin master —tags?

Daily use

git config —global "Your Name"
git config —global "moc.revetahw|liame_ruoy#moc.revetahw|liame_ruoy"

git add hello.html : stage the file hello.html
git commit -m "First Commit" : commit the staged files to the repository with the message "First commit".
git status : shows the current status of the local repository.
git checkout: checkout a version

Copying changes to a repository

Git Commit …: Copies the made changes to the local repository.
Push: Copies all the changes committed to the local repository, to the remote repository
Copying changes to a SVN repository: SVN DCommit

Getting changes from a (remote) repository

Pull will merge remote branch change to local branch which tracked with remote branch.
Fetch gets the changes from the remote branch and copies them to your local repository, but doesn't merge them to your working copy.
Getting changes from a SVN repository: SVN rebase

Remove tag

git tag -d release01
git push origin :refs/tags/release01

Push till a certain local commit

git push origin 2dc2b7e393e6b712ef103eaac81050b9693395a4:master


git branch : shows all local branches
git branch -a : shows local and remote branches
git branch branchname : creates a branch
git branch -d branchname : deletes a branch

Undo local commits and go back to origin/master

git reset —hard origin/master
Full explanation about git reset:

Revert a commit already pushed to a remote repository


git remote -v : list all remotes
git remote add origin https://{account}{name repository}

Other commands

git init : create a new repository
git —version : shows the version of git you are using
git config —list : shows the Git configuration settings in a list

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License