ict.ken.be

 

Posts in Category: Git

Add existing Git repository to Github 

Categories: Git
  • Create a new repository on github, without any files like readme, license, ...
  • Copy the Github repository REMOTE_URL
  • Open cmd in your existing git repository
  • git remote add origin  <REMOTE_URL>
  • git remote -v
  • git push --set-upstream origin master

 

Delete and purge last commit from Github on Windows 

Categories: Git
git reset --hard HEAD~1
git push --force

GitHub is down 

Categories: Git

So that's where unicorns go...

Unicorn displayed in browser

Export Mercurial into Git  

Categories: Git Mercurial

How sad that I have to write this post... proves once more that it's all about the marketing and communication, not so much the product.

Anyway, here how you can import your hg history into git using TortoiseHg

  • TortoiseHg > Global Settings > Extensions > Enable hggit
  • create a new git repo : git init --bare .git OR  git clone --bare https://git.ken.be/my-new-repo
  • cd to your hg repository and you might create a bookmark : hg bookmarks hg
  • hg push c:/path/to/your/new/git/repo
  • cd to your git repo
  • if you used init before: git config --bool core.bare false (when you used bare command before)
  • if you used a bookmark merge hg branch into master
  • push changes to remote repository
  • delete local version and get a normal clone.

And you have a new git repo with all your hg history in it. Awesome.

Or not so awesome: https://www.youtube.com/watch?v=CDeG4S-mJts 

Git Fundamentals - Notes 

Categories: Git

by James Kovacs

http://jameskovacs.com

  • Git created by Linus Torvalds, who also created Linux (because Bit-Keeper started asking him money)
  • Written in Perl and C

Advantages of DVCS

  • Different topologies (centralized, hierarchical, distributed)
  • Each clone is a full backup
  • Reliable branching/merging
  • Full local history (statistics, analyze regressions)
  • Deployment

Windows

Mac OSX

  • brew install git
  • DMG (http://git-scm.com/download/mac)

Linux

  • sudo apt-get install git-core (Debian/Ubuntu)
  • yum install git-core

Commands

git --version
git config --system (c:\Program Files\Git\etc\gitconfig)
git config --global (c:\Users\user\.gitconfig)
git config (stored in .git/config in each repo)

git config --global --list
git config --global help.autocorrect 1 (corrects your mispelled command)
git config --global color.ui auto
git config --global core.autocrlf true|false|input

git init

git status
git add foo.txt
git commit -m "my text"

git log

git diff dd6819..a15ec6
git diff HEAD~1..HEAD (~1 is one back from head revision)

git add -u (only adds updated files)
git add -A (all even untracked)

git checkout foo.txt (revert changes)
git reset --hard (revert all to head)
git reset --soft HEAD~1 (reorganize version)

git clean -n|-f (remove)

.gitignore
/logs/allthese.*
/bin

git clone https://foo.repo
git log --oneline | wc=1
git shortlog -sne (short name include number of commits and email)

git remote -v (where does the source come from)

git branch -r (include remote branches)

git remote add origin https://apullrequest
git fetch
git log origin/master
git merge origin/master
git branch -r

git branch --set-upstream master origin/master
git pull (shortcut of fetching and merging from an origin)
git remote add origin git@github.com:JamesKovacs/GitFundamentals.git (uses ssh key)
git push

git tag v1.0
git tag -a v1.0_with_message
git tag -s v1.0_signed
git push --tags

Protocols

  • https 80/443 https://github.com/jquery/jquery.git
  • git 9418 git://github.com/jquery/jquery.git
  • ssh 22 git@github.com:jquery/jquery.git
  • file n/a filepath

Branching, Merging, and Rebasing with Git

git log --graph --oneline --all --decorate
git config --global alias.lga "log --graph --oneline --all --decorate"
git lga
git reflog (about 30 days to get delete back)
git stash (rollback pending changes)
git stash list
git stash apply
git stash pop (apply and remove)
git stash drop
git stash branch 'feature2_additional'

git mergetool (eg. KDiff3, BeyondCompare)
git checkout bug1234
git rebase master
git rebase --continue

git branch v1.0_fixes v1.0
git checkout v1.0_fixes
git commit -am "Added fix1"
git commit -am "Added fix2"
git checkout master
git cherry-pick 6fa4324

git fetch origin master
git push
git push origin v1.0_fixes

More