cheatsheet-git-A4
cheatsheet-git-A4 copied to clipboard
CheatSheet For Git & GitHub
- Git CheatSheet :Tools: :PROPERTIES: :type: tool :export_file_name: cheatsheet-git-A4.pdf :END:
- PDF Link: [[https://github.com/dennyzhang/cheatsheet-git-A4/blob/master/cheatsheet-git-A4.pdf][cheatsheet-git-A4.pdf]], Category: [[https://cheatsheet.dennyzhang.com/category/tools/][tools]]
- Blog URL: https://cheatsheet.dennyzhang.com/cheatsheet-git-A4
- Related posts: [[https://cheatsheet.dennyzhang.com/cheatsheet-visualstudio-A4][Visual Studio CheatSheet]]
File me [[https://github.com/dennyzhang/cheatsheet-git-A4/issues][Issues]] or star [[https://github.com/dennyzhang/cheatsheet-git-A4][this repo]].
** Git Advanced
| Name | Comment |
|-------------------------------------+---------------------------------------------------------------------------------------|
| [[https://github.com/todotxt/todo.txt-android/wiki/Squash-All-Commits-Related-to-a-Single-Issue-into-a-Single-Commit][Git squash to make history clean]] | =git rebase -i HEAD~4=; =git push origin
** Git Remote | Name | Comment | |----------------------------------+------------------------------------------------------------------| | Git add a remote source | =git remote add upstream [email protected]:thoughtbot/dotfiles.git= | | [[https://stackoverflow.com/questions/10603671/how-to-add-a-local-repo-and-treat-it-as-a-remote-repo][Git add a local folder as remote]] | =git init .=, =git remote add bak /tmp/test_git_folder= |
** Git Commit
| Name | Comment |
|----------------------------------+-------------------------------------------------------------------------|
| [[https://github.com/todotxt/todo.txt-android/wiki/Squash-All-Commits-Related-to-a-Single-Issue-into-a-Single-Commit][Git squash to make history clean]] | =git rebase -i HEAD~4=; =git push origin
[[https://cheatsheet.dennyzhang.com/cheatsheet-git-A4][https://raw.githubusercontent.com/dennyzhang/cheatsheet-git-A4/master/git-concept.png]]
** Git Undo
| Name | Comment |
|-----------------+---------------------------|
| Undo git commit | =git reset --hard HEAD~1= |
| Undo git pull | =git reset --hard= |
| Undo git add | =git reset filename.txt= |
| Undo git merge | =git merge --abort= |
** Git log
| Name | Comment |
|--------------------------------------------------+-------------------------------------------------------------|
| git sh1sum | =git log -1 --pretty=format:%h= |
| Check recent commits | =git log -n 3= |
| Show change content between tow commits | =git log --pretty=oneline --abbrev-commit 1234...5678= |
| Check commit by username | =git log origin/master -n 3 --author
#+END_HTML
** Git Config
| Name | Comment |
|--------------------------+---------------------------------------------------------------------------------------------------------------------|
| Show git config | =git config --global/system= |
| Configure default editor | =export pager=cat=, =git config --global core.editor nano= |
| Edit git global config | =git config --global --edit= |
| Alias for git status | =git config --global alias.st status= [[https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases][Link: git aliases]] |
| Alias for git checkout | =git config --global alias.co checkout= |
| Alias for git commit | =git config --global alias.ci commit= |
| Reset git url | =git config --global url."[email protected]:dennyzhang/myrepo.git:".insteadOf "https://github.com/dennyzhang/myrepo/"= |
| Reference | [[https://github.com/github/gitignore][GitHub: gitignore examples]] |
** Git Branch
| Name | Comment |
|------------------------------+------------------------------------------|
| List all remote git branches | =git ls-remote --heads origin= |
| Delete local branch | =git branch -d <branch_name>= |
| Delete remote branch | =git push origin --delete <branch_name>= |
** Git Tag
| Name | Comment |
|-----------------------+--------------------------------------------------|
| Git list all tags | =git ls-remote --tags= |
| Git Fetch all tags | =git fetch --tags; git checkout tags/<tag_name>= |
| Git delete local tag | =git tag -d <tag_name>= |
| Git delete remote tag | =git push --delete origin <tag_name>= |
** Git Submodule
| Name | Comment |
|--------------------------------+------------------------------------|
| Git add a repo to current repo | =git submodule add <git_repo_url>= |
| Update submodule | =git submodule update= |
** GitHub
| Name | Comment |
|-----------------+---------------------------------------------------------------|
| Github Shortcut | [[https://help.github.com/articles/using-keyboard-shortcuts][Link: Using keyboard shortcuts]] |
| Generate TOC | [[https://www.dennyzhang.com/github_wiki#sec-1-2][gh-md-toc]] |
| Reference | [[https://www.dennyzhang.com/github_wiki#sec-1-3][link: generate link for code block]], [[https://www.dennyzhang.com/github_wiki#sec-1-1][link: git clone wiki repo]] |
** More Resources
https://github.com/git-tips/tips
License: Code is licensed under [[https://www.dennyzhang.com/wp-content/mit_license.txt][MIT License]].
<img align="bottom"src="https://www.dennyzhang.com/wp-content/uploads/sns/github.png" alt="github" />
#+END_HTML
- org-mode configuration :noexport: #+STARTUP: overview customtime noalign logdone showall #+DESCRIPTION: #+KEYWORDS: #+LATEX_HEADER: \usepackage[margin=0.6in]{geometry} #+LaTeX_CLASS_OPTIONS: [8pt] #+LATEX_HEADER: \usepackage[english]{babel} #+LATEX_HEADER: \usepackage{lastpage} #+LATEX_HEADER: \usepackage{fancyhdr} #+LATEX_HEADER: \pagestyle{fancy} #+LATEX_HEADER: \fancyhf{} #+LATEX_HEADER: \rhead{Updated: \today} #+LATEX_HEADER: \rfoot{\thepage\ of \pageref{LastPage}} #+LATEX_HEADER: \lfoot{\href{https://github.com/dennyzhang/cheatsheet-git-A4}{GitHub: https://github.com/dennyzhang/cheatsheet-git-A4}} #+LATEX_HEADER: \lhead{\href{https://cheatsheet.dennyzhang.com/cheatsheet-git-A4}{Blog URL: https://cheatsheet.dennyzhang.com/cheatsheet-git-A4}} #+AUTHOR: Denny Zhang #+EMAIL: [email protected] #+TAGS: noexport(n) #+PRIORITIES: A D C #+OPTIONS: H:3 num:t toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t #+OPTIONS: TeX:t LaTeX:nil skip:nil d:nil todo:t pri:nil tags:not-in-toc #+EXPORT_EXCLUDE_TAGS: exclude noexport #+SEQ_TODO: TODO HALF ASSIGN | DONE BYPASS DELEGATE CANCELED DEFERRED #+LINK_UP: #+LINK_HOME:
-
--8<-------------------------- separator ------------------------>8-- :noexport:
- DONE Github coveralls support traivs.ci python project :noexport: CLOSED: [2017-09-13 Wed 16:56] https://coveralls.zendesk.com/hc/en-us/articles/201342869-Python http://levibostian.com/blog/python-code-coverage-and-coveralls-io/ https://github.com/coveralls-clients/coveralls-python https://earldouglas.com/posts/python-ci.html http://blog.pythonity.com/coveralls-with-travis-ci-tox-pytest.html https://vevurka.github.io/dsp17/git/quality/django/python/travis_ci_frisor/ http://levibostian.com/blog/python-code-coverage-and-coveralls-io/ #+BEGIN_EXAMPLE Coveralls
Coveralls is a hosted analysis tool, providing statistics about your code coverage.
Configuring your Travis CI build to send results to Coveralls always follows the same pattern:
Add your repository to Coveralls. Configure your build to install the Coveralls library for the programming language you're using. Add Coveralls to your test suite. If you're using Travis CI for private repos, add service_name: travis-pro to your .coveralls.yml. We'll show you how to do this for Ruby in the following example. #+END_EXAMPLE
- DONE github: integrate docker auto build with dockerfile :noexport: CLOSED: [2017-09-13 Wed 18:49] https://hub.docker.com/r/niccokunzmann/dockerhub-build-status-image/ https://github.com/badges/shields/issues/886
- git :noexport:IMPORTANT:Personal: | Item | Comment | |-------------------------------+----------------------------------------------------------------| | man 7 gittutorial | man page for git tutorial | | gitk | git repository browser; sudo apt-get install gitk | | github保存密码 | git config remote.origin.url [email protected]:xiaozibao/test.git | | git change url of remote repo | git remote set-url origin git://new.url.here |
-
command list | Item | Comment | |-------------------------------------+-----------------------------------------------------------------| | 撤销本地修改 | git checkout dirname *.txt | | 撤销最近一次提交 | git revert --no-commit head | | git revert last change | git reset --soft HEAD^ | | revert a faulty branch merge | 789a4e8a3b436050082db5747762158aaca00a27 | |-------------------------------------+-----------------------------------------------------------------| | 创建一个本地branch | git branch denny | | 删除一个本地branch | git branch -d denny | | 把本地新创建的branch push到server | git push origin
| | 删除server一个branch | git push origin --delete <branchName> | | 合并branch | git merge | | 查看某个check-in的修改 | git diff ed3563a9538a183cb1e545458691ea6f626db898 | | git checkout file of given revision | git checkout 4d1c375e281627a7ea45b0b3abad08af51927851 server.py | -
git branch | git | svn | comment | |------------------------------+--------------------------------+---------------------------------------| | git branch branch | svn copy http://... http://... | BRANCHING | | git checkout branch | svn switch http://... | | | git branch | svn list http://.../ | | | git checkout rev | svn update -r rev | | | git checkout prevbranch | svn update | | | git checkout path | | Restore a file from the last revision | | git merge branch | | | | git push -u origin dev | | push a local branch to server |
-
git & svn | git | svn | Comment | |------------------------------------------------+--------------------------------+---------------------------------------| | git show HEAD~2 | | | | git clone url | svn checkout url | | | git pull | svn update | | | git tag -a sandbox-v2 -m "sandbox v2" | svn copy http://... http://... | | | git tag -l | svn list http://.../ | list local tags | | git push --tags | | push tag | | git show tag | svn log --limit 1 http://... | | | git init | | initialize the repository | | git add . | | add all files under current directory | | git show rev:path/to/file | | | | git blame path/to/file | | | | git diff rev path | svn diff -rrev path | | ** TODO git clone出来的,没有branch list ** TODO 生成补丁(patch),把补丁发送给主开发者 ** TODO git misc stuff :noexport: *** TODO git svn fetch failed **** console shot :noexport: #+BEGIN_EXAMPLE Item is not readable: Item is not readable at /usr/lib/git-core/git-svn line 1702 #+END_EXAMPLE *** TODO git generate diff in svn format :IMPORTANT:noexport: **** email from Ming #+BEGIN_EXAMPLE Hang already used pos-review to generate RB request from git diff. Hang, can you give us your experience on this? Thanks, Jason From: Zhang, Denny Sent: Wednesday, March 24, 2010 10:13 AM To: Zhang, Ming Cc: Chen, Jason (CIG); Zhou, Hang; Shen, Lizhong Subject: RE: generate diff from git for RB Hi Ming Hope the following solve your problem.
Problem: Reviewboard are expecting \t after filename.
The diff format of svn conform to the rule, while git diff format violate.
http://code.google.com/p/reviewboard/source/browse/trunk/reviewboard/diffviewer/parser.py?r=1361\
How reviewword parse
Sample of git diff format:
,-----------
| diff --git a/src/mgmt/pylib/mauiverify b/src/mgmt/pylib/mauiverify
| old mode 100644
| new mode 100755
| index a9eb2e0..0702120
| --- a/src/mgmt/pylib/mauiverify
| +++ b/src/mgmt/pylib/mauiverify
----------- Sample of SVN diff format: ,----------- | Index: mauiverify | =================================================================== | --- mauiverify (revision 49747) | +++ mauiverify (working copy) | @@ -25,12 +25,6 @@ | import random | import string | import pdb -----------
Solution: a shell script to convert git format to diff format
- Add a script of git-svn-diff to the $PATH(Show in the attachment).
Add the alias to the git configuration
[alias] svn-diff=!git-svn-diff
Generate diff by: git svn-diff
http://www.mail-archive.com/[email protected]/msg00864.html\ git-svn diff http://stackoverflow.com/questions/708202/git-format-patch-to-be-svn-compatable\ Git format-patch to be svn compatable? Thanks, Denny -----Original Message----- From: Zhang, Ming Sent: 2010年3月24日 3:26 To: Chen, Jason (CIG) Cc: Zhang, Denny; Zhou, Hang; Shen, Lizhong Subject: generate diff from git for RB Hi All Try to seek some idea, I tried to generate diff for RB but always get error like 'No valid separator after the filename was found in the diff header'. Did a quick check and could not find solution. Wonder if your guys have workaround? Thanks! Best Regards
- Ming Zhang
CIG, EMC Corporation
Thanks & Regards,
Denny Zhang
CIG Maui Sysmgmt Team
EMC ShangHai R&D -- Software Engineer
Tel: 86-21-60951100(2273)
Email: [email protected]
EMC²
Where information lives......
#+END_EXAMPLE
*** TODO generate diff from git for ReviewBoard
**** email from Hang
#+BEGIN_EXAMPLE
reviewboard support git-svn usage natively, its developers also use the same way. The discussion is available at.
http://groups.google.com/group/reviewboard/browse_thread/thread/3423e2c8f71c5c3a?pli=1\
Main steps:
(1) configure git, add rb address into .git/config
[reviewboard]
url = http://10.32.171.184
(2) use post-review with "--parent=
" You could also use the following options: --guess-summary --guess-description Then post-review will try to guess summary and description from git log. Thanks, Hang #+END_EXAMPLE *** TODO Install git in redhat **** TODO install by yum - install zlib-devel openssl-devel perl cpio expat-devel gettext-devel curl
- yum install git-core **** TODO install by configure/make/make install #+begin_example wget http://kernel.org/pub/software/scm/git/git-1.6.5.7.tar.gz && tar zxvf git-1.6.5.7.tar.gz && cd git-1.6.5.7 ./configure --prefix=/usr/local/git make install install-doc install-html /usr/local/git/bin/git --version #显示: git version 1.6.5.7 将git加入系统PATH ,----------- | vim /etc/profile #加入下面一行 | export PATH=$PATH:/usr/local/git/bin | source /etc/profile `----------- #+end_example **** useful link http://www.weekface.info/2010/01/03/linux-git-install\ Linux实做之Git分布式版本控制系统(安装git) *** TODO Switch google code from svn to git **** useful link http://code.google.com/p/support/wiki/ImportingFromGit\ ImportingFromGit http://hi.baidu.com/hunnon/blog/item/8a7b9c98e0f41b026f068c04.html\ 在 Google Code 中使用 Git *** TODO git svn set-tree git svn set-tree Reading from stdin... *** TODO check in git to svn #+begin_example $ git svn dcommit Committing to https://rd-accounting.googlecode.com/svn/trunk ... Authentication realm: https://rd-accounting.googlecode.com:443 Google Code Subversion Re pository Password for 'filebat.mark': Authentication realm: https://rd-accounting.googlecode.com:443 Google Code Subversion Re pository Username: filebat.mark Password for 'filebat.mark': Authentication realm: https://rd-accounting.googlecode.com:443 Google Code Subversion Re pository Username: filebat.mark Password for 'filebat.mark': Authorization failed: MKACTIVITY of '/svn/!svn/act/4b05885e-34b8-11df-b02f-4f7e9a581080': authorization failed: Could not authenticate to server: rejected Basic challenge (https:// rd-accounting.googlecode.com) at /usr/lib/git-core/git-svn line 3894 #+end_example *** TODO 如何将一个branch中的内容push到各一个branch :IMPORTANT: *** TODO git commit前,如何快捷地查看一个文件的修改 *** TODO 如何比较两个branch中同一个文件的异同 *** TODO Make "git blame" work for svn based repository :IMPORTANT: *** TODO Run difftool in git: git difftool [2/3] :IMPORTANT: http://luhman.org/blog/2009/08/25/git-difftool-and-vimdiff\ Git difftool and vimdiff **** TODO 如何在ntemacs中使用vimdiff **** DONE 在cygwin中vimdiff打开两个文件后,如何水平移动内容 CLOSED: [2010-03-21 星期日 01:27] **** DONE basic configuration CLOSED: [2010-03-21 星期日 01:26] git config --global diff.tool vimdiff git difftool -y *** TODO side by side code review :IMPORTANT:noexport:HARD: http://xhfamily.com/x/notes/20080819_git-process.html\ Git and side-by-side code review **** diff_view.py #+begin_src python #!/usr/bin/python
Take a review directory, like /tmp/20080813_14450,
1 read _file.list
2 print out a list of files for reviews
3 use vimdiff to review the diff
import sys, string, re, os
vertical filler to make alignment nice; more context is better; I don't use icase, iwhite
vimdiff="vim +":set nu" +":set nospell" +":syntax off" +":set diffopt=vertical,filler,context:8"" def Main(): if (len(sys.argv) != 2 and len(sys.argv) != 3): print "%s -l [review directory]"%sys.argv[0] sys.exit(1)
Get options
localDiff = False needToDeleteDiffDir = False reviewDir = "" if "-l" == sys.argv[1]: localDiff = True reviewDir = sys.argv[2] else: reviewDir = sys.argv[1]
Untar if needed
if os.path.isfile(reviewDir): os.system("tar zxvf %s -C /tmp"%reviewDir) reviewDir = "/tmp/%s"%(os.path.basename(reviewDir)[:-4]) needToDeleteDiffDir = True else: assert(os.path.isdir(reviewDir))
Parse _file.list from reviewDir
idxFileName = "%s/_file.list"%reviewDir if not os.path.isfile(idxFileName): print "Cannot find _file.list in the review directory!" sys.exit(1) f = open(idxFileName) prefix = reviewDir files = [] for line in f.readlines(): files.append(line[:-1]) f.close()
Now invoke vimdiff
i = -1;
while i < len(files):
printFiles(files);
print "Next/Previous/exit(N/p/x/
called from git diff to:
1. make a review directory in /tmp/ using date and parent pid, if not already there
2. append file name in /tmp/<data_ppid>/_file.list
3. copy the old and new version of the files according to the relative path
import sys, os, datetime
filler to make alignment nice; more context is better; I don't use icase, iwhite
vimdiff="vim +":set nu" +":syntax off" +":set diffopt=vertical,filler,context:8""
def Main():
ppid = os.getppid()
assert(ppid != 0)
today = datetime.datetime.now().strftime("%Y%m%d")
dir = "/tmp/%s_%05d"%(today, ppid)
idxFilePath = "%s/_file.list"%dir
gitFilePath = sys.argv[1]
gitOldFilePath = sys.argv[2]
gitNewFilePath = sys.argv[5]
copyOldFilePath = "%s/%s.BASE"%(dir, gitFilePath)
copyNewFilePath = "%s/%s"%(dir, gitFilePath)
os.system("mkdir -p %s"%dir)
os.system("touch %s"%idxFilePath)
idxFile = open(idxFilePath, "a")
if 0 == idxFile.tell():
print dir
idxFile.write("%s\n"%gitFilePath);
idxFile.close()
#print gitFilePath, gitOldFilePath, gitNewFilePath, copyOldFilePath, copyNewFilePath
copyFile(gitOldFilePath, copyOldFilePath)
copyFile(gitNewFilePath, copyNewFilePath)
return
def copyFile(fromPath, toPath):
os.system("mkdir -p %s"%os.path.dirname(toPath))
fromFile = open(fromPath, "r")
toFile = open(toPath, "w")
for line in fromFile.readlines():
toFile.write(line)
fromFile.close()
toFile.close()
return
Main()
#+end_src
**** gr.sh
#+begin_src sh
function gr {
if [ -z "$1" ]; then
reviewDir=GIT_EXTERNAL_DIFF=git_diff_to_review.py git diff
elif [ "$1" = "--cached" ]; then
reviewDir=GIT_EXTERNAL_DIFF=git_diff_to_review.py git diff --cached
else
reviewDir=GIT_EXTERNAL_DIFF=git_diff_to_review.py git diff "$1^" "$1"
fi
if [ -d "$reviewDir" ]; then
theDir=dirname $reviewDir
theBase=basename $reviewDir
pushd "$theDir" >/dev/null
tar zcf "$theBase.tgz" "$theBase"
popd >/dev/null
echo "$reviewDir.tgz"
rm -rf $reviewDir
else
echo "something wrong with $reviewDir"
fi
}
gr $1
#+end_src
*** TODO git pull . master fail: you are in the middle of a conflicted merge
**** HOW TO RESOLVE CONFLICTS
#+begin_example
HOW TO RESOLVE CONFLICTS
After seeing a conflict, you can do two things:.sp
o Decide not to merge. The only clean-ups you need are to reset the index file to the
HEAD commit to reverse 2. and to clean up working tree changes made by 2. and 3.;
git-reset --hard can be used for this.
o Resolve the conflicts. Git will mark the conflicts in the working tree. Edit the
files into shape and git-add them to the index. Use git-commit to seal the deal.
You can work through the conflict with a number of tools:.sp
o Use a mergetool. git mergetool to launch a graphical mergetool which will work you
through the merge.
o Look at the diffs. git diff will show a three-way diff, highlighting changes from
both the HEAD and remote versions.
o Look at the diffs on their own. git log --merge -p
Colors. Git can produce colorful output with some commands; since some people hate colors way more than the rest likes them, by default the colors are turned off. If you would like to have colors in your output:
git config --global color.diff auto git config --global color.status auto git config --global color.branch auto
Visualize. You may find it convenient to watch your repository using the gitk repository as you go.
#+end_example *** TODO git merge --no-commit branch to review the merge result and then do the commit yourself *** TODO git log -Sstring shows the commits which add or remove any file data matching string *** TODO git commit -a -m时, 如何处理不可见字符,例如回车,tab键 *** TODO git apply(patch -p0) ** DONE git diff: warning: terminal is not fully functional CLOSED: [2012-01-22 Sun 14:43] add to /etc/bash.profile
git config --global core.pager ""
或者export PAGER=cat *** useful link http://stackoverflow.com/questions/3952207/how-to-configure-emacs-app-to-use-git-within-shell-for-git-on-osx\ How to configure emacs.app to use git within shell for git on OSX - Stack Overflow
http://kerneltrap.com/mailarchive/git/2008/12/17/4443664/thread\\
Re: git-diff should not fire up $PAGER, period! | KernelTrap
** DONE git clone fail: error: server certificate verification failed CLOSED: [2012-11-14 Wed 15:26] git config --global http.sslVerify false #+begin_example denny@denny-Vostro-1014:~/backup/essential/Dropbox/private_data/code$ git clone https://[email protected]/bnow.git Cloning into 'bnow'... error: server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none while accessing https://[email protected]/bnow.git/info/refs fatal: HTTP request failed denny@denny-Vostro-1014:~/backup/essential/Dropbox/private_data/code$ git config --global http.sslVerify false denny@denny-Vostro-1014:~/backup/essential/Dropbox/private_data/code$ git clone https://[email protected]/bnow.git Cloning into 'bnow'... Password for 'https://[email protected]': 87ac515f138d3e1cc8dd58e6d4dc24a36b52cabd
remote: Counting objects: 1024, done. remote: Compressing objects: 100% (926/926), done. remote: Total 1024 (delta 422), reused 490 (delta 63) Receiving objects: 100% (1024/1024), 1.19 MiB | 1024 KiB/s, done. Resolving deltas: 100% (422/422), done. #+end_example ** sample configuration :noexport: [user] name = Zhang, Denny email = [email protected] [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true whitespace=fix,-indent-with-non-tab,trailing-space,cr-at-eol pager = less -FXRS [branch "branch-1"] remote = master [color] branch = auto diff = auto status = auto ui = true [color "branch"] current = yellow reverse local = yellow remote = green [color "diff"] meta = yellow bold frag = magenta bold old = red bold new = green bold whitespace = red reverse [color "status"] added = yellow changed = green untracked = cyan [tool] diff = vimdiff ** # --8<-------------------------- separator ------------------------>8-- ** TODO Git work with svn http://flavio.castelli.name/howto_use_git_with_svn\ Howto use Git and svn together
- install git and git-svn
- create the working dir: mkdir strigi
- init your git working dir: cd strigi && git-svn init https://svn.kde.org/home/kde/trunk/kdesupport/strigi git-svn init command is followed by the address of the svn repository (in this case we point to strigi's repository)
- Find a commit regarding the project (you can get it from cia version control). Warning: the command git-log will show project's history starting from this revision.
- Perform the command git-svn fetch -rREVISION Where REVISION is the number obtained before.
- Update your working dir: git-svn rebase ;; -------------------------- separator -------------------------- http://www.viget.com/extend/effectively-using-git-with-subversion/\ Effectively Using Git With Subversion ** useful link :IMPORTANT: http://git.or.cz/course/svn.html\ Git - SVN Crash Course http://flavio.castelli.name/howto_use_git_with_svn\ Howto use Git and svn together http://baike.baidu.com/view/1531489.htm?fr=ala0_1\ GIT http://www.cnblogs.com/1-2-3/archive/2010/07/18/git-commands.html ** DONE In eshell-mode of emacs, git commit can't open editor :IMPORTANT: CLOSED: [2010-03-19 星期五 23:46] 使用-m选项直接给出message, 或使用-f选项给一个文件名
If you don't pass any -m parameter or pass the -e parameter, your favorite $EDITOR will get run and you can compose your commit message there, just as with Subversion.
git commit -a -m "This is another test" *** consoleshot :noexport: #+BEGIN_EXAMPLE git commit -a error: Terminal is dumb but no VISUAL nor EDITOR defined. Please supply the message using either -m or -F option. #+END_EXAMPLE ** DONE git show rev:path/to/file CLOSED: [2010-03-19 星期五 23:56] *** consoleshot :noexport: #+BEGIN_EXAMPLE #+BEGIN_EXAMPLE git show 389fef009868695330c2d214df49c1ea6490111a commit 389fef009868695330c2d214df49c1ea6490111a Author: zhangd1 [email protected] Date: Fri Mar 19 23:52:57 2010 +0800 Test for verbose mode diff --git a/beta.el b/beta.el index 771288b..5adaa4d 100644 --- a/beta.el +++ b/beta.el @@ -1,6 +1,5 @@ ;; here is a test, another change (defun open-buffer-path2 ()
) (defun open-buffer-path () ;;Run explorer on the directory of the current buffer. d:/temp/git/dryrun $
#+END_EXAMPLE #+END_EXAMPLE ** DONE We can refer to latest revision by HEAD, its parent as HEAD^^ or HEAD~2. :IMPORTANT: CLOSED: [2010-03-20 星期六 00:42] ** DONE git diff rev path(svn diff -rrev path) CLOSED: [2010-03-20 星期六 00:47] To get a diff with an specific revision and path ** DONE Configure git colors :IMPORTANT: CLOSED: [2010-03-21 星期日 01:07]
Colors. Git can produce colorful output with some commands; since some people hate colors way more than the rest likes them, by default the colors are turned off. If you would like to have colors in your output:
git config --global color.diff auto git config --global color.status auto git config --global color.branch auto ;; -------------------------- separator -------------------------- http://jblevins.org/log/tools/git-colors\ Git Colors [color] branch = auto diff = auto status = auto [color "branch"] current = yellow reverse local = yellow remote = green [color "diff"] meta = yellow bold frag = magenta bold old = red bold new = green bold [color "status"] added = yellow changed = green untracked = cyan ** DONE customize configuration template :IMPORTANT: CLOSED: [2010-03-21 星期日 10:58] http://xhfamily.com/x/notes/20080819_git-process.html\
in .gitconfig
[commit] template = /path/to/.git.commit.template
in .git.commit.template
put your commit message title put your commit message details testing done: reviewers: ** DONE 如何列出两个branch的不同的地方: git diff $branch-name beta.el :IMPORTANT: CLOSED: [2010-03-21 星期日 11:15] ** DONE Try git and review board :noexport: CLOSED: [2010-03-21 星期日 19:08] *** good for git
- get different branches from various release
- search for various check-in
- check in to local, once the remote server is not accessible *** vimdiff Here are simple steps about how to view diff in "vimdiff" manner when input "git diff": http://technotales.wordpress.com/2009/05/17/git-diff-with-vimdiff/\ *** email 3 #+BEGIN_EXAMPLE Hi All, Right now we can support to use CLI to upload review request instead of using GUI which would be more efficient. This will speed up your review request creation. Please take a look at below wiki on the details and let me know if you have any question. http://tvg01.lss.emc.com/mediawiki/index.php/Effective_Code_Review_by_using_ReviewBoard#For_code_submitter_-_CLI_create_review_request\ The quick step to use this CLI is:
- Install RBtools (post-review) package
- Create your own reviewboard configuration ($HOME/.reviewboardrc)
- Create patch file after bug fixing
- Create review request by using post-review Thanks, Jason From: Chen, Jason (CIG) Sent: Thursday, March 04, 2010 10:40 PM To: Zhang, Ming; Yin, Caihua; Zhou, Hang; Zhang, Denny; Feng, Longda; Shen, Lizhong Cc: Zhao, Yubo; Kang, Sukwoo Subject: RE: Review board general process and user guide wiki. Right now we only support upload diff from GUI. I will learn to provide a CLI tool for us to easily upload the patch review without access GUI. I know we are all developers... ;) Btw, git format patch is not supported at this time. I will also dig more into RB to have a check. I will update wiki about our on-going status on the improvements. Thanks, Jason From: Zhang, Ming Sent: Thursday, March 04, 2010 10:24 PM To: Chen, Jason (CIG); Yin, Caihua; Zhou, Hang; Zhang, Denny; Feng, Longda; Shen, Lizhong Cc: Zhao, Yubo; Kang, Sukwoo Subject: RE: Review board general process and user guide wiki. thanks a lot. it looks great to me. how we upload today? if we can export the server as NFS and thus every developer just need to copy, or svn diff > foo://bar/x.diff, then it is a small work for coder.
From: Chen, Jason (CIG) Sent: Thursday, March 04, 2010 3:06 AM To: Yin, Caihua; Zhou, Hang; Zhang, Denny; Feng, Longda; Shen, Lizhong Cc: Zhao, Yubo; Zhang, Ming; Kang, Sukwoo Subject: Review board general process and user guide wiki. Hi all, I have drafted one wiki page about how to use Review Board for our bug fixing review or other code review. We can try to use this during our 1.3.1 bug fixing process and see whether it can improve our review efficiency and quality. The purpose is to help all of us for a better code review approach rather than using email. https://tvg01.lss.emc.com/mediawiki/index.php/Effective_Code_Review_by_using_ReviewBoard This wiki has contained all our necessary information and still under construction. I will update it with more information in following days. Without doubt, there always have improvement areas we need to refine during daily use. Please send me your feedbacks or directly modify wiki page in the future improvement sections. I appreciate for your any suggestions. Thanks, Jason #+END_EXAMPLE *** email 1 #+BEGIN_EXAMPLE Hello all, As time limited, I can only show you basic usage for reviewboard. Here is the reviewboard server IP which you can play around. You can register one user with your account name. http://10.32.171.184/\ If we feel there need more training, I can open another session for this. In the mean time, I will put the usage and instructions into wiki page. Feel free to let me know if you have any question or issues when use review board. Thanks, Jason -----Original Appointment----- From: Shen, Lizhong Sent: Thursday, February 04, 2010 12:46 PM To: Shen, Lizhong; Zhao, Yubo; Chen, Jason (CIG); Zhang, Denny; Zhou, Hang; Yin, Caihua; Feng, Longda Subject: Code review process discussion When: Thursday, February 04, 2010 2:00 PM-3:00 PM (GMT+08:00) Beijing, Chongqing, Hong Kong, Urumqi. Where: 蓬莱 (Fantasyland)(2F) Change:
-
postpone the meeting to 14:00~15:00 since Yubo will be in office about 2:00PM Agenda:
-
Brief introduction of Git (Lizhong)
-
How to leverage Git to review code (lizhong)
-
Reviewboard introduction (Jason) #+END_EXAMPLE *** email 2 #+BEGIN_EXAMPLE I agree. Git looks cool and powerful for developer if can master it very well while RB is more user friendly and easy to use. P.S. RB can support git but I haven't tried this before. You can have a try on this. I will send out the detail instructions later about setup and manage. Thanks, Jason From: Shen, Lizhong [mailto:[email protected]] Sent: Thursday, February 04, 2010 3:45 PM To: Chen, Jason (CIG) Cc: Zhao, Yubo; Zhang, Denny; Zhou, Hang; Yin, Caihua; Feng, Longda Subject: RE: Code review process discussion Hi all, Here is the wiki page for git: https://tvg01.lss.emc.com/mediawiki/index.php/Run_git_in_cig I think both RB and Git have their own advantage for code view. If RB could support Git well, that would be nice. Thanks! Lizhong, Shen GIG/Atmos 8621 60951100 ext 2272 -----Original Message----- From: Chen, Jason (CIG) [email protected] To: Shen, Lizhong [email protected], Zhao, Yubo [email protected], Zhang, Denny [email protected], Zhou, Hang [email protected], Yin, Caihua [email protected], Feng, Longda [email protected] Subject: RE: Code review process discussion Date: Thu, 4 Feb 2010 02:39:59 -0500 Hello all, As time limited, I can only show you basic usage for reviewboard. Here is the reviewboard server IP which you can play around. You can register one user with your account name. http://10.32.171.184/\ If we feel there need more training, I can open another session for this. In the mean time, I will put the usage and instructions into wiki page. Feel free to let me know if you have any question or issues when use review board. Thanks, Jason -----Original Appointment----- From: Shen, Lizhong Sent: Thursday, February 04, 2010 12:46 PM To: Shen, Lizhong; Zhao, Yubo; Chen, Jason (CIG); Zhang, Denny; Zhou, Hang; Yin, Caihua; Feng, Longda Subject: Code review process discussion When: Thursday, February 04, 2010 2:00 PM-3:00 PM (GMT+08:00) Beijing, Chongqing, Hong Kong, Urumqi. Where: 蓬莱 (Fantasyland)(2F) Change:
-
postpone the meeting to 14:00~15:00 since Yubo will be in office about 2:00PM Agenda:
-
Brief introduction of Git (Lizhong)
-
How to leverage Git to review code (lizhong)
-
Reviewboard introduction (Jason) #+END_EXAMPLE ** TODO Try git in emacs git commit -a -m "Schedule backup"; git svn dcommit *** TODO Try magit in emacs http://zagadka.vm.bytemark.co.uk/magit/magit.html\ magit manual | Key | Binding | |-----+--------------------------------| | $ | magit-display-process | | ! | magit-shell-command | | G | magit-refresh-all | | ? | magit-describe-item | | d | magit-diff-working-tree | | V | magit-show-branches | | X | magit-reset-working-tree | | b | magit-checkout | | e | magit-interactive-resolve-item | | l | magit-log | |-----+--------------------------------| | M-1 | magit-show-level-1-all | | M-2 | magit-show-level-2-all | | M-3 | magit-show-level-3-all | | M-4 | magit-show-level-4-all | mo-git-blame-current *** TODO customize check-in template in magit :IMPORTANT: *** TODO Magit Cheatsheet http://daemianmack.com/magit-cheatsheet.html\ Magit Cheatsheet *** ;; -------------------------- separator -------------------------- *** TODO "git push origin master" fail: 'master' does not appear to be a git repository $ git --no-pager push -v master branch-1 Pushing to master fatal: 'master' does not appear to be a git repository fatal: The remote end hung up unexpectedly Git exited abnormally with code 128. **** useful link http://stackoverflow.com/questions/922210/unable-to-git-push-master-to-github\ Unable to Git-push master to Github *** TODO git push master fail: ambiguous argument 'HEAD..master/branch-1' Unpulled commits: fatal: ambiguous argument 'HEAD..master/branch-1': unknown revision or path not in the working tree. Use '--' to separate paths from revisions *** TODO Work with Git from emacs http://alexott.net/en/writings/emacs-vcs/EmacsGit.html\ Work with Git from emacs http://www.michael-hammer.at/blog/emacs_git/\ Using Git with Emacs http://www.emacswiki.org/emacs/Git\ Git *** done **** DONE git blame, with the help of third party mo-git-blame CLOSED: [2010-03-21 星期日 12:05] http://www.bunkus.org/blog/2009/10/an-interactive-iterative-git-blame-mode-for-emacs/\ An interactive, iterative 'git blame' mode for Emacs ** # --8<-------------------------- separator ------------------------>8-- ** HALF git pull不太像svn up, 并没有拉回被删除的文件, 应该用git checkout ./smarty的类似命令 /sshx:[email protected]:/opt/local/bnow/bnow/priv/web
drwxr-xr-x 4 root root 4.0K Nov 28 11:28 smarty drwxr-xr-x 2 root root 4.0K Nov 28 11:28 smarty_plugins ** TODO git提交,但不产生新的提交历史记录 ** DONE [#A] git push失败 :IMPORTANT: CLOSED: [2013-02-25 Mon 17:07] export $DISPLAY unset SSH_ASKPASS
https://github.com/nlplab/brat/wiki/Installation This is due to SSH_ASKPASS being set to use gnome-ssh-askpass, see the discussion here. Just unset SSH_ASKPASS or set it to an empty string and you will be prompted for your password without the need for a GUI. Another fun note, on HTTPS you will receive a SSL certificate and old machines won't carry all the modern ones. To disable this prefix your git command with env GIT_SSL_NO_VERIFY=true, which of course isn't safe but works. For more SSH issues, see here.
#+begin_example [root@localhost circle_storage]# git push
(gnome-ssh-askpass:20840): Gtk-WARNING **: cannot open display: #+end_example ** DONE [#A] github保存密码: ssh :IMPORTANT: CLOSED: [2013-02-05 Tue 11:44] https://help.github.com/categories/56/articles git config --global user.name dennyzhang
git remote set-url origin https://dennyzhang:[email protected]/pomelo422/xiaozibao.git git push --repo https://dennyzhang:[email protected]/pomelo422/xiaozibao.git #+begin_example denny@denny-Vostro-1014:~/backup/essential/Dropbox/private_data$ git clone [email protected]:pomelo422/xiaozibao.git xiaozibao2 Cloning into 'xiaozibao2'... Permission denied (publickey). fatal: The remote end hung up unexpectedly denny@denny-Vostro-1014:~/backup/essential/Dropbox/private_data$ #+end_example ** DONE git pull fail: export GIT_SSL_NO_VERIFY=true CLOSED: [2013-06-14 Fri 16:39] git config --global http.sslVerify false https://help.github.com/articles/error-ssl-certificate-problem-verify-that-the-ca-cert-is-ok http://stackoverflow.com/questions/3777075/ssl-certificate-rejected-trying-to-access-github-over-https-behind-firewall #+begin_example /sshx:[email protected]: #$ git pull error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing https://git.ishopex.cn/zhangwei/event_trigger.git/info/refs
fatal: HTTP request failed
/sshx:[email protected]: #$ git config -l core.repositoryformatversion=0 core.filemode=true core.bare=false core.logallrefupdates=true remote.origin.fetch=+refs/heads/:refs/remotes/origin/ remote.origin.url=https://git.ishopex.cn/zhangwei/event_trigger.git branch.master.remote=origin branch.master.merge=refs/heads/master #+end_example ** DONE mac git review CLOSED: [2013-08-23 Fri 18:25] #+begin_example sudo -l curl http://python-distribute.org/distribute_setup.py | sudo python
curl http://pypi.python.org/packages/source/g/git-review/git-review-1.17.tar.gz > git-review.tar.gz tar zxvf git-review.tar.gz cd git-review-1.17 sudo python setup.py install
#+end_example
http://www.mediawiki.org/wiki/Gerrit/git-review
http://wikimania2012.wikimedia.org/wiki/Hackathon/Laptop_setup/OSX_git-review
*** DONE Could not connect to gerrit.: 没有把ssh的公钥传上去
CLOSED: [2013-08-23 Fri 18:25]
https://bugs.launchpad.net/git-review/+bug/1097278
#+begin_example
bash-3.2$ git-review
Could not connect to gerrit.
Enter your gerrit username: denny
Trying again with ssh://[email protected]:29418/sage-usb.git
<traceback object at 0x105c0bb90>
We don't know where your gerrit is. Please manually create a remote
named "gerrit" and try again.
Traceback (most recent call last):
File "/usr/local/bin/git-review", line 1196, in
git submodule foreach git pull origin master *** git subtree http://makingsoftware.wordpress.com/2013/02/16/using-git-subtrees-for-repository-separation/ https://github.com/apenwarr/git-subtree/blob/master/git-subtree.txt http://h2ik.co/2011/03/having-fun-with-git-subtree/ http://blogs.atlassian.com/2013/05/alternatives-to-git-submodule-git-subtree/ *** google repo https://code.google.com/p/git-repo/
http://source.android.com/source/developing.html *** GitSlave http://gitslave.sourceforge.net ** DONE [#A] git: How to complete a git clone for a big project on an unstable connection? CLOSED: [2015-07-28 Tue 11:30] git clone --depth 1 [email protected]:authright/iam.git --branch dev --single-branch
- get latest revision, instead of all
- get current version, instead of all
#+BEGIN_EXAMPLE [7/28/15, 12:07:53 AM] denny: As follow up for today's session share.
关于,git clone一个bitbucket/github十分慢的问题.
git没有断点续传的功能.但一个优化点是:如果你只想checkout某一个branch,那么下面的手段可以把你git clone的操作缩短50%左右. [7/28/15, 12:09:34 AM] denny: Run below command for comparison:
cd /tmp/tmp1 && git clone --depth 1 [email protected]:authright/iam.git --branch dev --single-branch
cd /tmp/tmp2 && git clone [email protected]:authright/iam.git http://stackoverflow.com/questions/3954852/how-to-complete-a-git-clone-for-a-big-project-on-an-unstable-connection http://stackoverflow.com/questions/14738219/how-to-resume-a-git-pull-clone-after-a-hung-up-unexpectedly #+END_EXAMPLE ** DONE rollback a git merge CLOSED: [2016-07-23 Sat 22:43] http://stackoverflow.com/questions/7099833/how-to-revert-a-merge-commit-thats-already-pushed-to-remote-branch https://mijingo.com/blog/reverting-a-git-merge Here's a complete example in the hope that it helps someone:
git revert -m 1
https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks http://stackoverflow.com/questions/4196148/git-pre-push-hooks http://stackoverflow.com/questions/1797074/local-executing-hook-after-a-git-push cd /Users/mac/Dropbox/private_data/osc/chef/iamdevops/cookbooks ls -1 | xargs rubocop
/Users/mac/Dropbox/private_data/work/totvs/code/mdmdevops/.git/hooks/pre_push *** .git/hooks/pre_push #+BEGIN_EXAMPLE #!/bin/bash -e
An example hook script to verify what is about to be pushed. Called by "git
push" after it has checked the remote status, but before anything has been
pushed. If this script exits with a non-zero status nothing will be pushed.
This hook is called with the following parameters:
$1 -- Name of the remote to which the push is being done
$2 -- URL to which the push is being done
If pushing without using a named remote those arguments will be equal.
Information about the commits which are being pushed is supplied as lines to
the standard input in the form:
This sample shows how to prevent push of commits where the log message starts
with "WIP" (work in progress).
remote="$1" url="$2"
z40=0000000000000000000000000000000000000000
IFS=' ' while read local_ref local_sha remote_ref remote_sha do if [ "$local_sha" = $z40 ] then # Handle delete : else if [ "$remote_sha" = $z40 ] then # New branch, examine all commits range="$local_sha" else # Update to existing branch, examine new commits range="$remote_sha..$local_sha" fi
# Check for WIP commit
commit=`git rev-list -n 1 --grep '^WIP' "$range"`
if [ -n "$commit" ]
then
echo "Found WIP commit in $local_ref, not pushing"
exit 1
fi
fi
done
cd ./cookbooks echo "test" >> /tmp/test.log ls -1 | xargs rubocop
exit 0
#+END_EXAMPLE ** TODO STDERR: fatal: Cannot force update the current branch https://discourse.chef.io/t/strange-git-behavior-any-suggestion-is-welcome/6408/4 https://github.com/chef/chef/issues/3025
#+BEGIN_EXAMPLE
This is the default behavior for the git resource. If you take a look at the docs, you'll see the checkout_branch attribute, whose description reads: "Use to specify the name of a branch to be checked out. Default value: deploy."
So, instead of using the revision attribute, you may, instead, want to specify the checkout_branch attribute.
What is happening right now is that it's checking out a branch called deploy from the revision you've set, but that's a bit confusing, based on what you're expecting to see. #+END_EXAMPLE
** DONE git shallow clone: set the parameter to -depth 1 CLOSED: [2016-10-18 Tue 19:32] https://blogs.gnome.org/simos/2009/04/18/git-clones-vs-shallow-git-clones/
http://stackoverflow.com/questions/6941889/is-it-safe-to-shallow-clone-with-depth-1-create-commits-and-pull-updates-aga https://www.perforce.com/blog/141218/git-beyond-basics-using-shallow-clones ** DONE git diff without context: git diff mdm-cluster/recipes/default.rb | grep -iE "^- |^+ " CLOSED: [2016-12-30 Fri 23:43] cd /Users/mac/backup/totvs_code/mdmdevops/dev/mdmdevops/cookbooks git diff mdm-cluster/recipes/default.rb #+BEGIN_EXAMPLE Denny-mac:mdm-cluster mac$ git diff recipes/default.rb diff --git a/cookbooks/mdm-cluster/recipes/default.rb b/cookbooks/mdm-cluster/recipes/default.rb index 6d4c6a3..c9a81db 100755 --- a/cookbooks/mdm-cluster/recipes/default.rb +++ b/cookbooks/mdm-cluster/recipes/default.rb @@ -37,13 +37,11 @@ end
hosts = node['common_basic']['couchbase_hosts'] if hosts.include?(hostname) || hosts.include?(ip_address)
- include_recipe 'common-basic::precheck_db' include_recipe 'couchbase-mdm::cluster' end
hosts = node['common_basic']['elasticsearch_hosts'] if hosts.include?(hostname) || hosts.include?(ip_address)
- include_recipe 'common-basic::precheck_db' include_recipe 'elasticsearch-mdm::cluster' end #+END_EXAMPLE ** DONE git get latest revision number: git rev-parse HEAD CLOSED: [2017-01-30 Mon 12:13] http://stackoverflow.com/questions/5724513/in-git-how-do-i-figure-out-what-my-current-revision-is ** # --8<-------------------------- separator ------------------------>8-- ** DONE [#A] commit binary files to git repo, truncate git history CLOSED: [2017-02-16 Thu 14:02] Finding and Purging Big Files From Git History https://rtyley.github.io/bfg-repo-cleaner/
http://naleid.com/blog/2012/01/17/finding-and-purging-big-files-from-git-history http://stackoverflow.com/questions/2100907/how-to-remove-delete-a-large-file-from-commit-history-in-git-repository
https://help.github.com/articles/removing-files-from-a-repository-s-history/ https://robinwinslow.uk/2013/06/11/dont-ever-commit-binary-files-to-git/
| Name | Summary | |------------------------------------------+--------------------------------------------------------------------| | Remove huge files from git log | java -jar bfg.jar --strip-blobs-bigger-than 100M some-big-repo.git | | Remove given file extension from git log | | | Check removed files | find . -name "REMOVED" |
git clone --mirror [email protected]:nubesecure/dofacdenny.git bfg --strip-blobs-bigger-than 50M dofacdenny.git
cd dofacdenny.git git reflog expire --expire=now --all && git gc --prune=now --aggressive
#+BEGIN_EXAMPLE denny zhang REPORTER Fix: https://bitbucket.org/nubesecure/dofacdenny/src/69237520613a7a0228ed95520c79e82d92d92beb/bitbucket-pipelines.yml?at=images&fileviewer=file-view-default Edit Pin to top Mark as spam Delete 2017-02-10 denny zhang REPORTER How to verify? git push to shrink-repo branch of dofacdenny, or run bitbucket pipeline in GUI
We shall see .git directory shrink into as smaller as ~132MB. And a clean git clone would take ~333MB #+END_EXAMPLE
git push
Trigger hook for penroz repo: https://bitbucket.org/nubesecure/penroz/addon/pipelines/home#!/results/branch/images/page/1
58MB: penroz/iamsvc/build/libs/iamsvc-1.0.0-SNAPSHOT.jar *** git-filter-branch *** DONE install bfg in ubuntu CLOSED: [2017-02-09 Thu 16:06] wget http://repo1.maven.org/maven2/com/madgag/bfg/1.12.15/bfg-1.12.15.jar java -jar ./bfg*.jar --strip-blobs-bigger-than 50M dofacdenny.git
cd dofacdenny.git git reflog expire --expire=now --all && git gc --prune=now --aggressive
git push ** DONE Git - push failure / This operation must be run in a work tree CLOSED: [2017-02-15 Wed 16:43] http://stackoverflow.com/questions/28412038/git-push-failure-this-operation-must-be-run-in-a-work-tree The remote repository in question is a bare repository.
It will only contain the packed objects and refs etc that git internally stores and won't have any of the regular code files checked out. As such, there will be no working tree, and hence no working git status.
That said, to check if your changes were pushed, just clone that repo in question to another location, and you will find your files all right:
git clone /opt/git/inventory.git some/location/inventory_clone You might need to do a git checkout master in the newly cloned repo to actually see the code files.
#+BEGIN_EXAMPLE cd /root/dofacdenny.git && git status && git push fatal: This operation must be run in a work tree #+END_EXAMPLE ** TODO Git repository size: git count-objects -v https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html ** DONE git status error: xcrun: error: invalid active developer path CLOSED: [2017-01-05 Thu 23:33] http://stackoverflow.com/questions/32893412/command-line-tools-not-working-os-x-el-capitan-macos-sierra http://apple.stackexchange.com/questions/254380/macos-sierra-invalid-active-developer-path
xcode-select --install: it will bring up a prompt to install the necessary command line tools.
#+BEGIN_EXAMPLE Denny-mac:shared mac$ git status xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun #+END_EXAMPLE ** DONE revert git PR merge: https://bitbucket.org/nubesecure/brozton/pull-requests/10/remove-docker-composeenv/diff CLOSED: [2017-03-11 Sat 17:40] http://stackoverflow.com/questions/38302119/revert-a-merged-pull-request-on-bitbucket
git revert -m 1 <SHA-1> git push
#+BEGIN_EXAMPLE https://bitbucket.org/nubesecure/brozton/pull-requests/10/remove-docker-composeenv/diff
Denny-mac:brozton mac$ git revert --no-commit head error: Commit 405b0fa98d0f471aa6c72266c6859738247ddc93 is a merge but no -m option was given. fatal: revert failed #+END_EXAMPLE ** DONE git pull: fatal: refusing to merge unrelated histories: --allow-unrelated-histories CLOSED: [2017-11-08 Wed 17:26] https://stackoverflow.com/questions/38255655/trying-to-pull-files-from-my-github-repository-refusing-to-merge-unrelated-his ** TODO github generate http link for two commits ** # --8<-------------------------- separator ------------------------>8-- :noexport: ** TODO git duet wf dz ** TODO git diff --cache ** TODO git: ~/.git-authors ** TODO git commit template ** HALF git duet dz jk *** customize email https://github.com/git-duet/git-duet pairs: jd: Jane Doe; jane fb: Frances Bar email: domain: awesometown.local email_addresses: jd: [email protected] ** TODO git lola ** TODO git checkout fails with "reference is not a tree": https://github.com/grpc/grpc/issues/3428 ** TODO git issue Denny-mac:sandbox-soterianetworks mac$ git pull customer denny-docker-sandbox From bitbucket.org:nubesecure/sandbox
- branch denny-docker-sandbox -> FETCH_HEAD fatal: refusing to merge unrelated histories ** TODO git pushd
- git commands :noexport: ** HALF git diff --cached ** HALF mac install git duet https://github.com/git-duet/homebrew-tap ** TODO update fly ** HALF git duet cat > ~/.git-authors << EOF authors: jk: Jason Keene; jkeene wf: Warren Fernandes; wfernandes wff: Warren Fernandes; dz: Denny zhang tc: Tom Chen; tochen email: domain: pivotal.io email_addresses: wff: [email protected] dz: [email protected] EOF ** HALF git pull -r ** TODO git reset @ ** TODO git reset @^ ** TODO git lola
-
--8<-------------------------- separator ------------------------>8-- :noexport:
- how people achieve this: https://github.com/kelseyhightower/nocode/issues/2524 :noexport:
- TODO Truncate .git /Users/zdenny/Dropbox/org_data :noexport:
- TODO git reset --hard HEAD :noexport:
- TODO Role Model :noexport: https://github.com/tiimgreen/github-cheat-sheet
- TODO make .git history small :noexport:
- TODO more content :noexport: ** git
To set your identity:
git config --global user.name "John Doe" git config --global user.email [email protected]
To set your editor:
git config --global core.editor emacs
To enable color:
git config --global color.ui true
To stage all changes for commit:
git add --all
To stash changes locally, this will keep the changes in a separate changelist
called stash and the working directory is cleaned. You can apply changes
from the stash anytime
git stash
To stash changes with a message
git stash save "message"
To list all the stashed changes
git stash list
To apply the most recent change and remove the stash from the stash list
git stash pop
To apply any stash from the list of stashes. This does not remove the stash
from the stash list
git stash apply stash@{6}
To commit staged changes
git commit -m "Your commit message"
To edit previous commit message
git commit --amend
Git commit in the past
git commit --date="date --date='2 day ago'"
git commit --date="Jun 13 18:30:25 IST 2015"
more recent versions of Git also support --date="2 days ago" directly
To change the date of an existing commit
git filter-branch --env-filter
'if [ $GIT_COMMIT = 119f9ecf58069b265ab22f1f97d2b648faf932e0 ]
then
export GIT_AUTHOR_DATE="Fri Jan 2 21:38:53 2009 -0800"
export GIT_COMMITTER_DATE="Sat May 19 01:01:01 2007 -0700"
fi'
To removed staged and working directory changes
git reset --hard
To go 2 commits back
git reset --hard HEAD~2
To remove untracked files
git clean -f -d
To remove untracked and ignored files
git clean -f -d -x
To push to the tracked master branch:
git push origin master
To push to a specified repository:
git push [email protected]:username/project.git
To delete the branch "branch_name"
git branch -D branch_name
To make an exisiting branch track a remote branch
git branch -u upstream/foo
To see who commited which line in a file
git blame filename
To sync a fork with the master repo:
git remote add upstream [email protected]:name/repo.git # Set a new repo git remote -v # Confirm new remote repo git fetch upstream # Get branches git branch -va # List local - remote branches git checkout master # Checkout local master branch git checkout -b new_branch # Create and checkout a new branch git merge upstream/master # Merge remote into local repo git show 83fb499 # Show what a commit did. git show 83fb499:path/fo/file.ext # Shows the file as it appeared at 83fb499. git diff branch_1 branch_2 # Check difference between branches git status # Show the changes from last commit
Commit history of a set of files
git log --pretty=email --patch-with-stat --reverse --full-index -- Admin*.py > Sripts.patch
Import commits from another repo
git --git-dir=../some_other_repo/.git format-patch -k -1 --stdout <commit SHA> | git am -3 -k
View commits that will be pushed
git log @{u}..
View changes that are new on a feature branch
git log -p feature --not master git diff master...feature
Interactive rebase for the last 7 commits
git rebase -i @~7
Diff files WITHOUT considering them a part of git
This can be used to diff files that are not in a git repo!
git diff --no-index path/to/file/A path/to/file/B
To pull changes while overwriting any local commits
git fetch --all git reset --hard origin/master
Update all your submodules
git submodule update --init --recursive
Perform a shallow clone to only get latest commits
(helps save data when cloning large repos)
git clone --depth 1
To unshallow a clone
git pull --unshallow
Create a bare branch (one that has no commits on it)
git checkout --orphan branch_name
Checkout a new branch from a different starting point
git checkout -b master upstream/master
Remove all stale branches (ones that have been deleted on remote)
So if you have a lot of useless branches, delete them on Github and then run this
git remote prune origin
The following can be used to prune all remotes at once
git remote prune $(git remote | tr '\n' ' ')
Revisions can also be identified with :/text
So, this will show the first commit that has "cool" in their message body
git show :/cool
Undo parts of last commit in a specific file
git checkout -p HEAD^ -- /path/to/file
Revert a commit and keep the history of the reverted change as a separate revert commit
git revert <commit SHA>
Pich a commit from a branch to current branch. This is different than merge as
this just applies a single commit from a branch to current branch
git cherry-pick <commit SHA1> ** patch
Patch one file
patch version1 < version.patch
Reverse a patch
patch -R version1 < version.patch
Patch all files in a directory, adding any missing new files
-p strips leading slashes
$ cd dir $ patch -p1 -i ../big.patch
Patch files in a directory, with one level (/) offset
patch -p1 -r version1/ < version.patch
- TODO git remote repo :noexport:
- Configure two remote endpoint
#+BEGIN_SRC sh git clone [email protected]:lrpdevops/denny-mydevops.git
git config remote.origin2.url [email protected]:denny/mydevops.git git config remote.origin.url [email protected]:lrpdevops/denny-mydevops.git
git pull origin2 sprint-37
File: .git/config
,-----------
| [core]
| repositoryformatversion = 0
| filemode = true
| bare = false
| logallrefupdates = true
| ignorecase = true
| precomposeunicode = true
| [remote "origin"]
| url = [email protected]:lrpdevops/denny-mydevops.git
| fetch = +refs/heads/:refs/remotes/origin/
| [branch "master"]
| remote = origin
| merge = refs/heads/master
| [remote "origin2"]
| url = [email protected]:denny/mydevops.git
| fetch = +refs/heads/:refs/remotes/customer/
`-----------
#+END_SRC
- [#A] gitlab :noexport:IMPORTANT: | Name | Summary | |-------------------------------------------------------------+---------| | /etc/gitlab/gitlab.rb | | | /var/opt/gitlab | | | /var/opt/gitlab/nginx/conf/gitlab-http.conf | | | /opt/gitlab | | | /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml | | |-------------------------------------------------------------+---------| | gitlab-ctl start | | | gitlab-ctl status | | | gitlab-ctl tail | | | /var/log/gitlab/nginx/gitlab_error.log | | | /var/log/gitlab | | | /var/opt/gitlab/gitlab-shell/config.yml | | |-------------------------------------------------------------+---------| | gitlab-rake gitlab:env:info | | | gitlab-rake gitlab:check | | ** DONE install gitlab CLOSED: [2015-12-20 Sun 22:16] https://about.gitlab.com/downloads/#ubuntu1404
devops-knowledgebase/code/docker_image/gitlab.dockerfile
#+BEGIN_EXAMPLE ########## How To Use Docker Image ###############
Install docker utility
Download docker image: docker pull denny/gitlab:latest
Start container:
docker run -t -d --privileged --name my-test -h test -p 8081:80 denny/gitlab:latest /bin/bash
docker exec -it my-test bash
ps -ef | grep runsvdir-start
nohup /opt/gitlab/embedded/bin/runsvdir-start &
gitlab-ctl start
curl http://127.0.0.1:80
##################################################
FROM denny/ruby2:latest MAINTAINER DennyZhang.com [email protected]
########################################################################################
TODO: to be implemented
https://about.gitlab.com/downloads/#ubuntu1404
apt-get install curl openssh-server ca-certificates postfix lsof curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash apt-get install gitlab-ce gitlab-ctl reconfigure
Browse in GUI: Username/Password: root/5iveL!fe
######################################################################################## #+END_EXAMPLE ** DONE [#A] gitlab import project from bitbucket CLOSED: [2015-12-24 Thu 12:56] http://stratus3d.com/blog/2015/09/06/migrating-from-bitbucket-to-local-gitlab-server/ http://opensourceame.com/transitioning-from-bitbucket-to-gitlab/
The BitBucket import script will use the BitBucket API to add the public key as a deploy key for each repository your import, then clone down the repository via SSH and remove the deploy key once the import is complete. *** change /etc/gitlab/gitlab.rb *** restart gitlab *** misc #+BEGIN_EXAMPLE Integrate your server with Bitbucket
Import projects from Bitbucket and login to your GitLab instance with your Bitbucket account. To enable the Bitbucket OmniAuth provider you must register your application with Bitbucket. Bitbucket will generate an application ID and secret key for you to use. Sign in to Bitbucket. Navigate to your individual user settings or a team's settings, depending on how you want the application registered. It does not matter if the application is registered as an individual or a team - that is entirely up to you. Select "OAuth" in the left menu. Select "Add consumer". Provide the required details. Name: This can be anything. Consider something like "<Organization>'s GitLab" or "<Your Name>'s GitLab" or something else descriptive. Application description: Fill this in if you wish. URL: The URL to your GitLab installation. 'https://gitlab.company.com' Select "Save". You should now see a Key and Secret in the list of OAuth customers. Keep this page open as you continue configuration. On your GitLab server, open the configuration file. For omnibus package: sudo editor /etc/gitlab/gitlab.rb For instalations from source: cd /home/git/gitlab
sudo -u git -H editor config/gitlab.yml See Initial OmniAuth Configuration for initial settings. Add the provider configuration: For omnibus package: gitlab_rails['omniauth_providers'] = [ { "name" => "bitbucket", "app_id" => "YOUR_KEY", "app_secret" => "YOUR_APP_SECRET", "url" => "https://bitbucket.org/" } ] For installation from source:
- { name: 'bitbucket', app_id: 'YOUR_KEY', app_secret: 'YOUR_APP_SECRET' } Change 'YOUR_APP_ID' to the key from the Bitbucket application page from step 7. Change 'YOUR_APP_SECRET' to the secret from the Bitbucket application page from step 7. Save the configuration file. If you're using the omnibus package, reconfigure GitLab (gitlab-ctl reconfigure). Restart GitLab for the changes to take effect. On the sign in page there should now be a Bitbucket icon below the regular sign in form. Click the icon to begin the authentication process. Bitbucket will ask the user to sign in and authorize the GitLab application. If everything goes well the user will be returned to GitLab and will be signed in. Bitbucket project import
To allow projects to be imported directly into GitLab, Bitbucket requires two extra setup steps compared to GitHub and GitLab.com. Bitbucket doesn't allow OAuth applications to clone repositories over HTTPS, and instead requires GitLab to use SSH and identify itself using your GitLab server's SSH key. Step 1: Public key
To be able to access repositories on Bitbucket, GitLab will automatically register your public key with Bitbucket as a deploy key for the repositories to be imported. Your public key needs to be at ~/.ssh/bitbucket_rsa.pub, which will expand to /home/git/.ssh/bitbucket_rsa.pub in most configurations. If you have that file in place, you're all set and should see the "Import projects from Bitbucket" option enabled. If you don't, do the following: Create a new SSH key: sudo -u git -H ssh-keygen When asked Enter file in which to save the key specify the correct path, eg. /home/git/.ssh/bitbucket_rsa. Make sure to use an empty passphrase. Configure SSH client to use your new key: Open the SSH configuration file of the git user. sudo editor /home/git/.ssh/config Add a host configuration for bitbucket.org. Host bitbucket.org IdentityFile ~/.ssh/bitbucket_rsa User git Step 2: Known hosts
To allow GitLab to connect to Bitbucket over SSH, you need to add 'bitbucket.org' to your GitLab server's known SSH hosts. Take the following steps to do so: Manually connect to 'bitbucket.org' over SSH, while logged in as the git account that GitLab will use: sudo -u git -H ssh bitbucket.org Verify the RSA key fingerprint you'll see in the response matches the one in the Bitbucket documentation (the specific IP address doesn't matter): The authenticity of host 'bitbucket.org (207.223.240.182)' can't be established. RSA key fingerprint is 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40. Are you sure you want to continue connecting (yes/no)? If the fingerprint matches, type yes to continue connecting and have 'bitbucket.org' be added to your known hosts. Your GitLab server is now able to connect to Bitbucket over SSH. Restart GitLab to allow it to find the new public key. You should now see the "Import projects from Bitbucket" option on the New Project page enabled. #+END_EXAMPLE ** DONE gitlab enable git clone: ssh with git: make sure ssh 22 port is listening CLOSED: [2015-12-24 Thu 23:21] ** DONE gitlab enable git clone: url incorrect CLOSED: [2015-12-24 Thu 23:42] sed -i "s/external_url 'http://gitlab'/external_url 'http://git.jinganiam.com'/g" /etc/gitlab/gitlab.rb ** DONE [#A] gitlab: configure email sending: /etc/gitlab/gitlab.rb CLOSED: [2015-12-25 Fri 15:32] Use smtp instead of sendmail/postfix. https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/smtp.md
https://gist.github.com/xavierjurado/3138813
/var/log/gitlab/gitlab-rails/production.log #+BEGIN_EXAMPLE SMTP settings
If you would rather send application email via an SMTP server instead of via Sendmail, add the following configuration information to /etc/gitlab/gitlab.rb and run gitlab-ctl reconfigure. There are example configurations at the end of this page. gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.server" gitlab_rails['smtp_port'] = 465 gitlab_rails['smtp_user_name'] = "smtp user" gitlab_rails['smtp_password'] = "smtp password" gitlab_rails['smtp_domain'] = "example.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
If your SMTP server does not like the default 'From: gitlab@localhost' you
can change the 'From' with this setting.
gitlab_rails['gitlab_email_from'] = '[email protected]' gitlab_rails['gitlab_email_reply_to'] = '[email protected]' #+END_EXAMPLE
#+BEGIN_EXAMPLE root@gitlab:/var/log/gitlab# tail /var/log/gitlab/gitlab-rails/production.log Processing by Admin::UsersController#new as HTML Completed 200 OK in 139ms (Views: 100.3ms | ActiveRecord: 7.2ms)
Sent mail to [email protected] (980.2ms)
Sent mail to [email protected] (1090.8ms)
Sent mail to [email protected] (948.7ms)
Sent mail to [email protected] (1033.7ms) #+END_EXAMPLE ** DONE gitlab delete deployed key CLOSED: [2015-12-26 Sat 11:49] http://doc.gitlab.com/ee/api/deploy_keys.html#delete-deploy-key https://groups.google.com/forum/#!topic/gitlabhq/Ak9pgY6u-vw ** TODO gitlab add default reviewers for each repo ** TODO [#B] gitlab import bitbucket repo timeout https://gitlab.com/gitlab-org/gitlab-ee/commit/4535db04b28996baf118bafeb77acd16065e5c5a
http://git.jinganiam.com/authright/iam/import/new
#+BEGIN_EXAMPLE Import repository
The repository could not be imported. Cloning into bare repository '/var/opt/gitlab/git-data/repositories/authright/iam.git'... fatal: early EOF Git repository URL The repository must be accessible over http://, https:// or git://. If your HTTP repository is not publicly accessible, add authentication information to the URL: https://username:[email protected]/group/project.git. The import will time out after 4 minutes. For big repositories, use a clone/push combination. To migrate an SVN repository, check out this document. #+END_EXAMPLE ** TODO [#A] gitlab fail to connect #+BEGIN_EXAMPLE ==> /var/log/gitlab/nginx/gitlab_access.log <== 123.57.240.189 - - [28/Dec/2015:15:14:02 +0000] "GET /users/sign_in HTTP/1.1" 500 415 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36" 123.57.240.189 - - [28/Dec/2015:15:14:02 +0000] "GET /static.css HTTP/1.1" 304 0 "http://git.jinganiam.com/users/sign_in" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36" 123.57.240.189 - - [28/Dec/2015:15:14:02 +0000] "GET /favicon.ico HTTP/1.1" 200 5430 "http://git.jinganiam.com/users/sign_in" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"
==> /var/log/gitlab/gitlab-rails/production.log <== Started GET "/users/sign_in" for 123.57.240.189 at 2015-12-28 15:14:01 +0000 Processing by SessionsController#new as HTML Completed 500 Internal Server Error in 26ms (ActiveRecord: 1.5ms)
ActionController::UrlGenerationError (No route matches {:action=>"passthru", :controller=>"omniauth_callbacks", :provider=>:saml} missing required keys: [:provider]): app/controllers/sessions_controller.rb:98:in `auto_sign_in_with_provider' #+END_EXAMPLE ** TODO gitlab add reviewers ** DONE gitlab check version: gitlab-rake gitlab:env:info CLOSED: [2016-04-11 Mon 20:19] #+BEGIN_EXAMPLE ]0;root@my-gitlab: /var/opt/gitlab/nginxroot@my-gitlab:/var/opt/gitlab/nginx# gitlab-rake gitlab:env:info gitlab-rake gitlab:env:info
System information System: Ubuntu 14.04 Current User: git Using RVM: no Ruby Version: 2.1.7p400 Gem Version: 2.2.5 Bundler Version:1.10.6 Rake Version: 10.4.2 Sidekiq Version:3.3.0
GitLab information Version: 8.2.3 Revision: 19daba8 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql URL: http://gitlabcn.dennyzhang.com HTTP Clone URL: http://gitlabcn.dennyzhang.com/some-group/some-project.git SSH Clone URL: [email protected]:some-group/some-project.git Using LDAP: no Using Omniauth: no
GitLab Shell Version: 2.6.8 Repositories: /var/opt/gitlab/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks/ Git: /opt/gitlab/embedded/bin/git ]0;root@my-gitlab: /var/opt/gitlab/nginxroot@my-gitlab:/var/opt/gitlab/nginx# #+END_EXAMPLE ** DONE gitlab reset user's password: Admin area -> Users CLOSED: [2016-04-12 Tue 10:33] ** DONE [#A] gitlab reconfigure nginx redirect url: /opt/gitlab/bin/gitlab-rake db:schema:load db:seed_fu CLOSED: [2016-04-14 Thu 08:47] https://gitlab.com/gitlab-org/omnibus-gitlab/issues/244 http://stackoverflow.com/questions/26660084/external-url-must-include-a-fqdn
Recipe: gitlab::default
- link[/opt/gitlab/service/gitlab-git-http-server] action delete (up to date) Recipe: gitlab::database_migrations
- execute[initialize gitlab-rails database] action nothing (skipped due to action :nothing)
- execute[initialize gitlab-ci database] action nothing (skipped due to action :nothing)
- bash[migrate gitlab-rails database] action nothing (skipped due to action :nothing)
- bash[migrate gitlab-ci database] action nothing (skipped due to action :nothing) Recipe: gitlab::gitlab-rails
- execute[clear the gitlab-rails cache] action run
- execute /opt/gitlab/bin/gitlab-rake cache:clear
- TODO git logl :noexport:
-
--8<-------------------------- separator ------------------------>8-- :noexport:
- TODO git cat-file :noexport:
- TODO git server hook :noexport: https://www.atlassian.com/git/tutorials/git-hooks
- HALF how to truncate git history :noexport: https://gist.github.com/montonero/1196514 https://passingcuriosity.com/2017/truncating-git-history/
#+BEGIN_EXAMPLE #!/bin/bash git checkout --orphan temp $1 git commit -m "Truncated history" git rebase --onto temp $1 master git branch -D temp #+END_EXAMPLE
https://stackoverflow.com/questions/37937984/git-refusing-to-merge-unrelated-histories-on-rebase git pull --allow-unrelated-histories
#+BEGIN_EXAMPLE The default behavior has changed since git 2.9:
"git merge" used to allow merging two branches that have no common base by default, which led to a brand new history of an existing project created and then get pulled by an unsuspecting maintainer, which allowed an unnecessary parallel history merged into the existing project. The command has been taught not to allow this by default, with an escape hatch --allow-unrelated-histories option to be used in a rare event that merges histories of two projects that started their lives independently. #+END_EXAMPLE
-
--8<-------------------------- separator ------------------------>8-- :noexport:
- TODO git cheatsheet: https://jimmysong.io/cheatsheets/git-tricks :noexport:
- TODO consolidate & beyond: https://github.com/arslanbilal/git-cheat-sheet :noexport:
- TODO consolidate https://github.com/tchapi/markdown-cheatsheet :noexport:
- TODO github shortcut keys in github: t -> search by filename :noexport: https://help.github.com/categories/keyboard-shortcuts/
- TODO github shortcut to jump in between files :noexport:
-
--8<-------------------------- separator ------------------------>8-- :noexport:
- TODO How to undo a git pull? :noexport:
- TODO undo local git commit :noexport:
- TODO git undo: git add :noexport:
-
--8<-------------------------- separator ------------------------>8-- :noexport:
- TODO git backport :noexport:
- TODO GitHub/GitLab markdown image size :noexport:
#+BEGIN_EXAMPLE


 You can skip the HEIGHT
 #+END_EXAMPLE
- TODO git get branch name from git commit hash :noexport: https://stackoverflow.com/questions/2706797/finding-what-branch-a-git-commit-came-from
git branch --contains b1f5eb736a19e3be00c7c1a535f367b5fb8928bb b1f5eb736a19e3be00c7c1a535f367b5fb8928bb
- TODO git find out which commit has deleted a file/folder :noexport:
- TODO git HTTPS ACCESS :noexport: https://github.com/JeffDeCola/my-cheat-sheets/tree/master/software/development/source-version-control/git-cheat-sheet#https-access-using-netrc
- TODO consolidate: https://github.com/JeffDeCola/my-cheat-sheets/tree/master/software/development/source-version-control/git-cheat-sheet#https-access-using-netrc :noexport:
-
--8<-------------------------- separator ------------------------>8-- :noexport:
- github add an image :noexport: https://stackoverflow.com/questions/14494747/add-images-to-readme-md-on-github
Try this markdown:
I think you can link directly to the raw version of an image if it's stored in your repository. i.e.

- TODO markdown add code snippet :noexport:
-
--8<-------------------------- separator ------------------------>8-- :noexport:
- HALF [#A] git add alias for repo, and use two different ssh keys :noexport: https://gist.github.com/jexchan/2351996 https://medium.freecodecamp.org/manage-multiple-github-accounts-the-ssh-way-2dadc30ccaca
Host github.com-jexchan HostName github.com User git IdentityFile ~/.ssh/id_rsa_jexchan
- TODO Git push to a new remote after shallow clone :noexport: https://stackoverflow.com/questions/27614458/git-push-to-a-new-remote-after-shallow-clone
- TODO git push --force-with-lease vs. --force :noexport: https://stackoverflow.com/questions/52823692/git-push-force-with-lease-vs-force http://weiqingtoh.github.io/force-with-lease/



