1. General Tasks

1.1 Creating a new repository

First initialise the repository

git init

Write code, then commit.

git commit

1.2 Clone a repository

 
git clone https://github_url/project-name.git

1.3 Changing a repositories' remote URL

git remote set-url origin https://github_url/project-name.git

2. Branches

2.1 List Branches

To list all branches in the current repository.

git branch -a

2.2 New Branch

To create a new branch named newBranchName, where BaseBranchName is the base branch.

git checkout -b newBranchName BaseBranchName

Note: BaseBranchName is optional

2.3 Change Working Branch

Change working branch to BranchName.

git checkout BranchName

2.4 Delete a Branch

git branch -d BranchName

2.5 Delete a Remote Branch

git push RemoteRepositoryURL -d BranchName

3. Tags

3.1 List All Tags

git tag

3.2 Delete a Tag

git tag -d TagName

3.2 Sync Local/Remote Tags

git fetch --prune --tags

4. Subtress

4.1 Add a new Subtree from a remote repository

git subtree add --prefix LocalFolder RemoteRepoURL.git BranchName --squash

4.2 Update a Subtree from a remote repository

git subtree pull --prefix LocalFolder RemoteRepoURL.git BranchName --squash

4.2 Remove a Subtree

git remote rm LocalFolder