博文

目前显示的是标签为“git”的博文

Git rewriting local history - update previous (but not the last) commit

Suppose you haven't done any merge or push, and there is no change in the stage. Now you realize you want to make some change in one of your previous commit you haven't pushed yet. 1. Start interactive rebase process with the last 3 commit, suppose the oldest 3th commit is the one you want to update. git rebase -i HEAD~3 2. Edit the rebase command in the poped editor. From: pick f7f3f6d changed my name a bit pick 310154e updated README formatting and added blame pick a5f4a0d added cat-file # Rebase 710f0f8..a5f4a0d onto 710f0f8 # # Commands: #  p, pick = use commit #  e, edit = use commit, but stop for amending #  s, squash = use commit, but meld into previous commit # # If you remove a line here THAT COMMIT WILL BE LOST. # However, if you remove everything, the rebase will be aborted. # To: edit f7f3f6d changed my name a bit pick 310154e updated README formatting and added blame pick a5f4a0d added cat-file # Rebase 710f0f8..a5f4a0d onto 71...

Install git on windows and use it in cygwin

You have two options when install git: Install mysisgit https://code.google.com/p/msysgit/downloads/list Install git from cygwin Recommendation is to use option 1, because by that you always get the latest git version.  After install mysisgit on your windows machine, you should add git_install_folder/bin/ to your path environment variable so that cygwin can find it. Add the following configuration settings from cygwin: git config --global core.askpass "git-gui–-askpass" git config --global credential.helper store git config --global core.eol lf git config --global core.autocrlf false git config --global core.filemode false // ignore file mode(chmod) change in git

在GIT中找回丢失的commits

有时候我们commit了一些change在local repository中,但是不小心丢掉了这些commits. 比如说我们reset 到了origin/master, 这时候如何找回这些已经commit的东西,来挽回我们之前做的工作呢? 方法便是使用 git reflog 运行git reflog 我们可以看到我们执行过的git命令以及执行后的branch在哪个local revision. 找到需要的那个revision然后运行git reset --hard <revision> 我们就可以回到从前了。

What I did to reproduce the consequence of misuse of git merge commit

图片
Git is a powerful tool. More power means more responsibility.  We use git in our project. There are several developers so the commits are quite frequent.  Symptom:  Sometimes we see our changes and corresponding commits disappears after some developer do their merge commit. Their merge commit seems to have reverted away commits which has been done earlier by others.  In the commit log we see the guilty merge commit behavior very strange: It has two parent A and B. A is the guilty developer's local commit branch, and B is the other developer's commits branch. Strangely the merged commit would choose the status of A instead B in the merged results for files that has been changed and committed in commit branch B(which is other developers' commit). So the consequence is that after the merge commit, the changes has been committed and pushed by other developer will "gone"! The status of the   files from other developers' commit are "...

Git error "Could not write new index file"

1. 检查看是不是disk space用光了 2. 如果问题出在index file上 $ rm -f .git/index $ git reset 3. 如果问题出在packfile上 $ git index-pack

Git - Solution to huge git object folder

如果你的disk space 不够大,而你又有一个巨大的object folder 在 .git 文件夹下你可以使用以下办法: A. 1. git fsck list all unreachable blobs 2. git prune delete unreachable blobs 或者 B. 1. git reflog expire --expire=now 2. git repack -ad remove dangling files from pack files 3. git prune 或者 C. git gc --aggressive --prune 或者 D. 删除 一些old and huge files in object/pack 文件夹...

How to change only case of filename when using git on windows

1. If you need to rename a file and also change its content, do it in two steps: A. change its name B. modify its content 2. On non-FAT file system use following command: git mv -f name.java Name.java 3. On FAT system, follow these steps: A. rename name.java to something.java B. rename something.java to Name.java 4. There is a config parameter in git might help in case problem with case of filenames: git config core.ignorecase Use git config -l  to list config parameter and check core.ingorecase parameter setting