GIT Cheetsheet

Contributers: Mick Mifsud

Modified: 3 years ago

Page Permission: Public - Revision: 727

 

Branches

Create a new remote branch:

$ git checkout -b {branch_name}
$ git push --set-upstream origin {branch_name}

Checkout a remote branch locally

$ git checkout -t origin/{branch_name}
$ composer update --prefer-source

Delete a GIT branch and track it remotely:

$ git push --delete origin {branch_name}
$ git branch -d {branch_name}

Rename/Move a remote branch

$ git checkout <old_name>
$
git branch -m old-branch new-branch
git push origin --delete <old-branch>
git push origin -u <new_branch>

Merge a branch into master

$ git checkout master
$ git merge {branch_name}

Tags

Delete a Tag:

$ git push --delete origin {tag_name}
$ git tag -d {tag_name}

Remotes:

View the remote URL:

$ git remote -v

Change repository name:

$ git remote set-url origin {git-repo-url}

Bugs:

Fix ssh default https issue:

$ git config --global url.ssh://git@github.com/.insteadOf https://github.com/
$ git config --global url.ssh://git@bitbucket.org/.insteadOf https://bitbucket.org/

Misc Handy Commands

Git pull and overwrite changes:

$ git reset --hard
$ git pull
--OR--
$ git fetch --all
$ git reset --hard origin/master
$ git pull

Tag a past commit:

$ git tag -a 2.2.99 f42901ea6183ea2c1939dd8d6092cde4da54813b -m 'Code before major upgrade'
$ git push --tags

Create New TkLib Project:

Clone the base TkLib project and remove the original .git repository files:

FORMAT: git clone -b <branch> <remote_repo>
$ git clone -b 3.2 git@github.com:tropotek/tkuni.git <projectName>
$ cd <projectName>
$ rm -rf .git

Now create a new project on your Git server (github or bitbucket) and type the following commands:
(Note: Remember to give access to all developer for commits)

$ git init
$ git remote add origin git@bitbucket.org:fvas-elearning/<projectName>.git
$ git add .
$ git commit -m "initial Commit"
$ git push -u origin master

Now we need to create a new branch for the major version so we can track version branches:

$ git checkout -b 3.0
$ git push --set-upstream origin 3.0

Update the projects Composer.json to the values needed. (See examples in other sites for more info on this)

Be sure to create a blank Database if one is needed ready for the site to be set-up.

Then run composer to get all dependencies and install the base DB and answer all questions as needed.

$ composer install
...

For the final setup you will need to open your browser to the site base URL and complete the setup form.