_git_assume.bat
# git 忽略本地已存在文件的修改
# 将文件修改忽略
git update-index --assume-unchanged _config.yml
git update-index --assume-unchanged Gemfile.lock
git update-index --assume-unchanged .gitmodules
_git_no-assume.bat
# git 忽略本地已存在文件的修改
# 取消文件忽略
git update-index --no-assume-unchanged _config.yml
git update-index --no-assume-unchanged Gemfile.lock
_git_ls-files.bat 显示所有忽略:
git ls-files -v | grep '^h\ '
git checkout master
git pull
/**
不用 /*
。
git checkout 分支名 目录 1/** 目录 2/**
git checkout dev check/**
git add *
git commit -m "merge"
git push
git.exe pull --progress --no-rebase -v "origin"
git.exe fetch -v --progress "origin"
git pull --rebase
git stash
代码暂存出栈,代码本地暂存是用的栈的方式,可以连续多次更改后 stash,pop 后依次出栈:
git stash pop
git rebase --abort
退出 rebase 忽略后的蓝色背景状态:
esc
shift + :+ q
enter
撤销本地提交的代码:
git revert
git revert --continue
git revert --abort
git submodule update --init --recursive
git pull --rebase
拉取,从服务器拉取代码到本地,加 –rebase 会跟本地提交的代码进行合并。
git stash
git stash pop
代码暂存出栈,代码本地暂存是用的栈的方式,可以连续多次更改后 stash,pop 后依次出栈。
git merge pdf_1208_ebook_fb
将分支合并到当前分支。
分支合并后若存在冲突,在本地使用 ui 工具解决冲突后,使用以下命令继续,没用问题后就可以 push。
git merge --continue
有时从服务器拉取代码与本地代码 rebase 时会出现处理不当导致状态错误,需要忽略。
git rebase --abort
退出 rebase 忽略后的蓝色背景状态。
esc
shift + :+ q
enter
git reflog -5(5 表示最近 5 个版本)
输出:b27fd592 HEAD@{24}: commit: [engine][0505] message log info.
git reset HEAD~1
重置当前目录到某个版本(有时本地提交后发现有问题,想撤销本地提交,并改为修改的状态)
git reset b27f (版本号,git reflog 查看的输出前面 4 个字符)
git revert
git revert --continue
git revert --abort
git submodule update --init --recursive
有时 git checkout 无法拉到分支,则先用 fetch,再 checkout。
git fetch
git branch 查看分支
git branch -D test(分支名)
删除本地分支,一个目录下最好不要超过 3 个分支,已经发布的分支正常就从本地删掉, 否则时间久了后 git 会在某个时刻触发整理目录,需要耗时非常久。
Git svn clone 的方式使用 SVN
git svn clone http://svn.example.com/path/to/project-x/trunk project-x
git svn clone http://svn.example.com/project
git svn clone http://svn.example.com/project/repo -s # The -s flag assumes that your repository uses the "trunk, branches, tags" convention.
Clone the trunk from Subversion
r26810 = 5d592be1aa91b1ecc3c3f6044ff4348783ecf7e1 (refs/remotes/git-svn)
A ...
fatal: Cannot open '.git/Git_svn_delta_16584_0_msC_ea': Invalid argument
hash-object -w --stdin-paths --no-filters: command returned error: 128
error closing pipe: Bad file descriptor at D:\Program Files\Git\mingw64/libexec/git-core\git-svn line 0.
(in cleanup) hash-object -w --stdin-paths --no-filters: command returned error: 72057594037927935
----
fatal: Cannot open '.git/Git_svn_delta_4600_0_KJGiZh': Invalid argument
开始老不成功,后来发现是 Windows Defender 误删除了文件,选择允许即可继续 fetch。
Continuing an interrupted git-svn clone
$ git svn clone http://svn.example.com/project/trunk project
# download, download, download, break!
$ cd project; ls -a
.git
$ git svn fetch
# download, download, download, success!
$ ls -a
.git
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# deleted: foo.c
# deleted: foo.h
#
$ git reset --hard; ls -a1
.git
foo.c
foo.h
Once the clone is finally completed, you probably want to generate a .gitignore file based on Subversion’s meta data:
git svn show-ignore >> .gitignore
How to git-svn clone the last n revisions from a Subversion repository? https://stackoverflow.com/questions/747075/how-to-git-svn-clone-the-last-n-revisions-from-a-subversion-repository
git svn clone -s -r1450:HEAD some/svn/repo
as workaround for some old SVN Repos from us, im use the param -r to ignore very old commits. The first git commit after migration contains the last content from commit 1 - 1450 octaviordz/git-svn–skip-error
https://git-scm.com/docs/git-svn
# 克隆一个 svn trunk
git svn clone http://svn.example.com/project/trunk
# 进入文件夹 trunk
cd trunk
# You should be on master branch, double-check with 'git branch'
git branch
# Do some work and commit locally to Git:
git commit ...
# Something is committed to SVN, rebase your local changes against the
# latest changes in SVN:
git svn rebase
# Now commit your changes (that were committed previously using Git) to SVN,
# as well as automatically updating your working HEAD:
git svn dcommit
# Append svn:ignore settings to the default Git exclude file:
git svn show-ignore >> .git/info/exclude
# Clone a repo with standard SVN directory layout (like git clone):
git svn clone http://svn.example.com/project --stdlayout --prefix svn/
# Or, if the repo uses a non-standard directory layout:
git svn clone http://svn.example.com/project -T tr -b branch -t tag --prefix svn/
# View all branches and tags you have cloned:
git branch -r
# Create a new branch in SVN
git svn branch waldo
# Reset your master to trunk (or any other branch, replacing 'trunk'
# with the appropriate name):
git reset --hard svn/trunk
# You may only dcommit to one branch/tag/trunk at a time. The usage
# of dcommit/rebase/show-ignore should be the same as above.
If multiple people (or one person with multiple machines) want to use git svn to interact with the same Subversion repository, you can do the initial git svn clone to a repository on a server and have each person clone that repository with git clone:
# Do the initial import on a server
ssh server "cd /pub && git svn clone http://svn.example.com/project [options...]"
# Clone locally - make sure the refs/remotes/ space matches the server
mkdir project
cd project
git init
git remote add origin server:/pub/project
git config --replace-all remote.origin.fetch '+refs/remotes/*:refs/remotes/*'
git fetch
# Prevent fetch/pull from remote Git server in the future,
# we only want to use git svn for future updates
git config --remove-section remote.origin
# Create a local branch from one of the branches just fetched
git checkout -b master FETCH_HEAD
# Initialize 'git svn' locally (be sure to use the same URL and
# --stdlayout/-T/-b/-t/--prefix options as were used on server)
git svn init http://svn.example.com/project [options...]
# Pull the latest changes from Subversion
git svn rebase