IT-SDK-Git

From wiki.samerhijazi.net
Revision as of 15:35, 13 February 2020 by Fiducia (talk | contribs) (Credential Storage)
Jump to navigation Jump to search

Resource

ssh

type %userprofile%\.ssh\id_rsa.pub | clip
cat %userprofile%\.ssh\id_rsa.pub | clip

Settings

git config --global user.name "Samer Hijazi"
git config --global user.email "samer.hijazi@samerhijazi.net"
...
git config http.receivepack true
git update-server-info

Credential

  • default: no cache at all
  • cache: keeps credentials in memory for a certain period of time.
  • store: saves the credentials to a plain-text file on disk.
  • Mac-Chain: in Mac caches credentials in the secure keychain "osxkeychain".
  • Windows-Chain: in Windows caches credentials in the secure keychain.
git config --global credential.helper cache
git config --global credential.helper 'store --file ~/.my-credentials'
git config --global credential.helper manager
git config --global credential.helper wincred
git config --global --edit
...
git credential-manager version

init

git init --bare         # Initial Repo for remote
git init                # Initial Repo for local
...
git remote add origin https://samerhijazi@gitlab.com/samerhijazi/public.git

Life Cycle

git clone ssh://ssh-w0000000@servername.com/www/htdocs/w0000000/repository/git/projectname.git
git pull
git add README.md
git commit -m "First commit"
git push -u origin master

Branching

$ git checkout -b myfeature develop        # create a new brach from develop
$ git branch -m feature1 feature2          # To rename a local Git branch
$ git push -u origin feature2:feature3     # To rename a remote Git branch
...
$ git branch -a 		# list all branches
$ git branch -r 		# list all updated branches
$ git branch -d myfeature       # delete branch 
...
$ git fetch			# update the list of remote branches
$ git fetch --prune		# remove remote branches that not longer have a counterpart.
$ git push origin --delete test # delete origin branch

Taging

$ git tag -d $(git tag -l)	         # Delete All local tags. (Optional Recommended)
$ git fetch				 # Fetch remote All tags. (Optional Recommended)
$ git push origin --delete $(git tag -l) # Delete All remote tags. Pushing once should be faster than multiple times
$ git tag -d $(git tag -l)	         # Delete All local tags.

Remove

$ git checkout master
$ git rm -r $FILE_NAME
$ git commit -m "My Massage"
$ git push origin master

Reset

$ git stash  # Save all local changes und remove them from workspace. 
$ git fetch  # fetch from the default remote, origin
$ git reset --hard origin/master # reset your current branch (master) to origin's master

Workflow

########### Feature #########################
$ git checkout -b myfeature develop
...
$ git checkout develop
$ git merge --no-ff myfeature
$ git branch -d myfeature
...
$ git push origin develop
########### Release #########################
$ git checkout -b release-1.2 develop
$ git commit -a -m "Bumped version number to 1.2"
...
$ git checkout master
$ git merge --no-ff release-1.2
$ git tag -a 1.2
...
$ git checkout develop
$ git merge --no-ff release-1.2
$ git branch -d release-1.2
########### Hotfix #########################
$ git checkout -b hotfix-1.2.1 master
$ git commit -a -m "Bumped version number to 1.2.1"
...
$ git checkout master
$ git merge --no-ff hotfix-1.2.1
$ git tag -a 1.2.1
...
$ git checkout develop
$ git merge --no-ff hotfix-1.2.1
$ git branch -d hotfix-1.2.1