Skip to main content

Git

GIT

Tags

Loggit tag -a v0.1 -m "tagname"
git tag v0.1
Delete
git tag -d v0.1

Branch

Create branch
git branch stage
Check what branch you are in
git status
git log

--oneline

List--decorate
whichgit filesbranch have-a
Switch been modifiedbranches or stagedrestore locally

working
tree files.
git statuscheckout

Commitstage
push changes


git add .
git commit -m "Fixed Something"blablabla"
git push -u origin master
stage

Merge

Pull

Change
gitbranch initto master
git pullcheckout http://git.myhypervisor.ca/myhypervisor/project.git
master
Merge

Fetch

git fetchmerge stage
Delete local
git branch -d stage
Delete remote
git push --all
delete origin stage

Merge conflicts

Changesgit thestatus

URL

FIND CONFLICT & FIX SHIT

git add .
git commit -m "blablabla"
git merge stage

Create a branch based off of themaster

repository.

git checkout -b stage master

Edit files

git commit -a -m "Adds new feature"
git checkout master
git rebase stage

Revert

git revert HEAD

or find a commit has with

git log --oneline --decorate
git revert

Git log

git log
git log --graph
git log --since="4 days ago"
git log -S
git log --stat
git log --shortstat
git log --pretty=format:"%h - %an - %ar - %s"

See diff before commit

Git diff

Remote

git remote set-urlshow origin

http://git.myhypervisor.ca/myhypervisor/project.git

Cleaning

Create a remote repo pointing on your existing GitHub repository

git remotegc add--prune
origingit http://git.myhypervisor.ca/myhypervisor/project.gc --auto
git
 config gc.pruneexpire "30 Days"

Add new repo

git config --global user.name "username"
git config --global user.email "email@email.com"
Create a new repository
git clone http://git.myhypervisor.ca/myhypervisor/project.git
cd project
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

Existing folder

cd existing_folder
git init
git remote add origin http://git.myhypervisor.ca/myhypervisor/project.git
git add .
git commit -m "Initial commit"
git push -u origin master

Existing Git repository

cd existing_repo
git remote rename origin old-origin
git remote add origin http://git.myhypervisor.ca/myhypervisor/project.git
git push -u origin --all
git push -u origin --tagsĀ