Git & Git Server for linux
$git config –global core.quotepath false
git push origin --all -u
git push g --all -u
Internal Git Server in 5 Minutes
- Install linux server, Ubuntu Server 14.04 in my case.
- Install Git Server, GitLab in my case. follow the steps here.
- Config email setting following the steps here. Edit
/etc/gitlab/gitlab.rb
and rungitlab-ctl reconfigure
. This step is necessary when add git users. Gmail SMTP In my case. - Open Browser in Client, and log into server, add projects, add users.
- for each project , add readme.md, and commit in browser
- go to "Settings" of this project, "Protected branches" of settings, "Unprotect" the project.
- Grant the users with right the project by going to "Project"-->"Settings" --> "Members", and click "Add members" button.
- Now, enjoy your personal internal Git Server.
Git Learning Resources:
- One of the best book <<Pro Git>> free to download downloaded at https://progit.org/
- ***** Learn Branching *****
Git dos and donts
The does
- Write useful, readable commit message
- use topic branches locally
- small, logical commits
- do choose a workflow
The don'ts
- Don't rebase public commits
- Don't delete unmerged remote branches
- Don't more than 1 project per repo.
- Don't create a very large repo.
Reference
This document contains related resources to install Git Server.Install Gitlab Server on Ubuntu:
- Follow the steps here to install gitlab
- Config email setting following the steps here. Edit
/etc/gitlab/gitlab.rb
and rungitlab-ctl reconfigure
Git Client for Windows:
1: TortoiseGit on Windows:
- Refer to this youtube for usage.
- Easier to use, but not work in git way
2: SourceTree
- Use source tree for branching and merging, it's log and graph viewer is best by far. according to here
- Say hello to SourceTree for Windows 1.5
- does not provide explorer integration
3: Smart Git:Better Diff Viewer
4: Git with Visual Studio
5. Comparison between different client
- Comparison between SourceTree Tortoise Git, and other Clients. here.
- Peter's thoughts on SourceTree GUI
- Discussions on stackoverflow.
- Link: Stash Git: Source Tree Vs TortoiseGit.
- Getting started with SourceTree, Git and git flow.
- How do I configure Visual Studio 2013 for use with Git/SourceTree.
Git Conflict Resolving:
- Very nice video on: Resolving merge conflicts in Git - Tutorial for Laura.
- Git Merge with BeyondCompare, refer to here
Misc:
Git Commands:
- git branch testing, git checkout testing
- gitk --all
- git log --oneline --graph --decorate --all
- git config --global alias.glog "git log --oneline --graph --decorate --all"
- git push -u secondary --all
- Gold Rebase Rule:
- Never rebase commits that you have pushed to a public repository
Fix Git
- git commit --amend: wrong commit
- git reset HEAD <file>
- git checkout -- <file> : give up change
- Tags:
- annotated
- lightweight
- git tag -a -m -lw
- git push [remote] --tags
- Cherry-Pick: git cherry-pick <commit name> <branch name>
- Bisect: binary search to find good commit or bad commit
- Stash: switch branches without committing work
- Revert: git revert <commit>
- Reset: reset vs revert 12:00
Most Common Command
*** Git Main ***
Git: branch early, branch often=== Git Merge ===
- git branch newImage
- git checkout newImage
- git commit
- git checkout master
- git merge newImage
- git checkout bufFix
- git rebase master
- git checkout master
- git rebase bufFix
- git HEAD^
- git HEAD^^
- git HEAD~2
- git branch -f master HEAD~3
- git reset : only works on local repo: git reset HEAD^
- git revert: git revert HEAD: actually create a new snapshot
- cherry-pick: git cherry-pick <Commit1> <Commit2> <...>
- interactive rebase: git rebase -i HEAD~4 --aboveAll
- Locally stacked commits
- git rebase -i HEAD~2 git commit --amend
- git rebase -i HEAD~2 git rebase caption master
- git rebase parentCommit childCommit
*** Git Remote ***
git clone, fit fetch, git pull- git pull
- Equal
- git cherry-pick o/master
- git rebase o/master
- git merge o/master
- git pull == git fetch; git merge o/master
- git fakeTeamwork
- git fakeTeamwork foo 3
- git pull --rebase
- git pull; git push
- git checkout -b foo o/master; ==> branch set to track o/master
- if the foo branch is currently checked out, can leave off: git branch -u o/master
- git branch -u o/master foo;
- git push origin <src>:<dest>
- git fetch origin <src>:<dest>
- git fetch origin foo: remote:foo branch ==> o/foo
- --- to compare between local and remote/branch ---
- git push origin :foo ==> delete remote branch
- git fetch origin :bar ==> create local branch
===
Introduction Sequence===
[ ] Introduction
[ ]
Ramping Up
[ ]
Moving Work Around
[ ]
A Mixed Bag
[ ]
Advanced Topics
=== rename tag ===
Here is how I rename a tag old to new:
git tag new old
git tag -d old
git push origin :refs/tags/old
git push g --tags
=== Git Status Back ===
- If you want to revert changes made to your working copy, do this:
- git checkout .
- If you want to revert changes made to the index (i.e., that you have added), do this:
- git reset
- Warning this will reset all of your unpushed commits to master!
- If you want to revert a change that you have committed, do this:
- git revert ...
- If you want to remove untracked files (e.g., new files, generated files):
- git clean -f
- Or untracked directories:
- git clean -d
=== Check Ignored Files ===
git status --ignored
git clean -ndX
for not ignore empty folder, add .gitkeep
Git for large Projects with Many SubProjects
Each module need to have separate version numbers. And we use
- git-describe
- git bisect
- git-subtree.
- Choosing between Single or multiple projects in a git repository?
- Detach subdirectory into separate Git repository
- git filter-branch
- git subtree
- git submodules
- git submodule add git://github.com/chneukrichen/rack.git ThisFolder/ThisSubFolder
- git submodule update
- Split out existing repository into subtree
Setup a git difftool and mergetool.
Easy Security - Microsoft Dynamic Nav Classic
Mastering Git Subtree
Adding a subtree - manual
http://a/testtry/plugin.git
http://a/testtry/main.git
http://a/testtry/myown.git
git remote add plugin ../remotes/plugin
git fetch plugin
git read-tree --prefix=vendor/plugins/demo -u plugin/master
git commit -m "Added demo plugin subtree in vendor/plugins/demo"
Grabbing/updating a repo that uses subtrees
git push
git clone remotes/main colleague
cd colleague
tree vendor
Git Diff and Merge Tools
- install DiffMerge ----commercial
- git config --global ... setting up several parameters
- git difftool
- git mergetool
Git Power Routines - How To Solve Conflicts [5 8]
- git checkout --ours/--theirs actors.md
Using vimdiff as your git diff tool..mp4
- Threesome.vim
Git Workflow
- as SVN - Monly Master Branch
- feature Branch
- Gitflow
Git Large Project
- Fetching Less Data: Git LFS
- Shallow clones
- Narrow clones
- Android checkout 500 repositories when you download it.
- Handle multiple repositories:
- Repo: just a little Python wrapper
- ... with some extra features
- ... and an XML parser
- Git submodule
- Server
- Clone Bitmaps
- Clone Bundles
Becoming a Git Master
- Git Liquid Prompt is awesome
- aliases are stored in .gitconfig
- git config --global rerere.enabled true
- git config --global rebase.autosquash true
- lock down your repo
- signing release tags is often all you need
- Handle project dependencies with git
- Git and project dependencies: http://bit.do/git-deps
- RepoBuild: written in C++
- Facebook Buck: Github, used to build android
- Pants Build : runs on linux and mac OSX, BuckBuild for android:
- Other
- The power of git sub-tree
- Self Defined Class:
Facebook Buck
manually/main (master u=) $ git checkout -b split-plugin
manually/main (split-plugin) $ git filter-branch \ --subdirectory-filter lib/plugins/myown
Labels: Config Management, Git, Version Control