Git: Ignoring a folder tree except a particular sub-folder
Monday, February 7th, 2011So, this will exclude any sub-folders form a but will include the sub-sub-sub-folder a/b/c and exclude the file a/b/c/file.xml
a/* !b a/b/* !c a/b/c/file.xml
So, this will exclude any sub-folders form a but will include the sub-sub-sub-folder a/b/c and exclude the file a/b/c/file.xml
a/* !b a/b/* !c a/b/c/file.xml
in the home folder (~), edit (or create) the .profile file with the following
# Set git autocompletion and PS1 integration
if [ -f /usr/local/git/contrib/completion/git-completion.bash ]; then
. /usr/local/git/contrib/completion/git-completion.bash
fi
GIT_PS1_SHOWDIRTYSTATE=true
if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi
PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\$'
Edit the from git/share/git-gui/lib/database.tcl and change
if {$objects_current >= $object_limit} {
set objects_current [expr {$objects_current * 250}]
set object_limit [expr {$object_limit * 250}]
if {[ask_popup \....
by:
if {$objects_current >= $object_limit && false} {
set objects_current [expr {$objects_current * 250}]
set object_limit [expr {$object_limit * 250}]
if {[ask_popup \....
Source: Stackoverflow: How to skip “Loose Object” popup when running ‘git gui’
When git-am fails to cleanly apply It will ask you to apply it yourself, to git add the file and to run git-am --resolved.
In fact, git-am can help you a lot. When the call to git-am for a patch fails, simply run :
git-am --3way
Il will merge the file that can be automatically merge. Some files may be marked with CONFLICT and in this case, edit them to do a manual merge, and once they are fixed and run
git add $FILES_IN_CONFLICT git-am --resolved
% git checkout -b bugfix_from_john master % git am < /path/to/saved/message
% git checkout master % git merge bugfix_from_john % git branch -d bugfix_from_john
git checkout -b my_new_branch
git branch -a
git fetch --all #get the remote branches git branch -a #fetch a remote branch as local (assuming remote branch remotes/origin/dev) git branch dev remotes/origin/dev
git reset --hard
abandon everything since your last commit; this command can be DANGEROUS. If
merging has resulted in conflicts and you’d like to just forget about the
merge, this command will do that.
git reset --hard HEAD^
git revert HEAD
git clean -f
clean directory as well:
git clean -fd
If you just want to remove ignored files, run “git clean -f -X”. If you want to remove ignored as well as non-ignored files, run “git clean -f -x”
git mv -f name.java Name.java
git am --abort
Tag a specific branch
git tag stable-1 1b2e1d63ff
Viewing available tags is done with -l:
git tag -l
Annotated tag:
git tag -a -m "Tagging release 1.0" v1.0
Viewing tags with annotation:
git tag -l -n1
Delete a tag:
git tag -d tag_name
Push tags:
git push origin --tags
Git log with tags
git log --decorate=short
git checkout -f -b [new branch name] [tag]/[sha1]
git rebase -i HEAD~4
Prevent to change a file
git update-index --assume-unchanged full/file/path.ext
Undo
git update-index --no-assume-unchanged full/file/path.ext
Create a repository:
> cd projectA > git init
Add all the files
> git add .
Commit
> git commit
Create empty bare repository (on server http://myserver.com/)
> cd /var/www/html/projectAPub > git --bare init > git --bare update-server-info
Make sure the hooks/post-update is enabled (see doc)
New way:
mv hooks/post-update.sample hooks/post-update
Old way:
> cd ./hooks > chmod +x post-update
Add the remote
> cd projectA > git remote add origin ssh://username@myserver.com/var/www/html/projectAPub
Push to the public repository (origin)
> git push origin master
> git clone http://myserver.com/projectAPub projectA
This will create a “remote” with the default name “origin”
Show remote branch(es)
> git remote show origin
Track a remote branch (fetch to make sure you have the latest remote definition)
> git fetch > git branch --track other_branch origin/other_branch
Make sure you have the EPEL Repository installed in your yum repository, do the following:
Install Git with
> yum install git
You should get something like:
============================================================================= Package Arch Version Repository Size ============================================================================= Installing: git x86_64 1.5.5.6-2.el5 epel 3.5 M Installing for dependencies: perl-Error noarch 1:0.17010-1.el5 epel 26 k perl-Git x86_64 1.5.5.6-2.el5 epel 16 k Transaction Summary ============================================================================= Install 3 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 3.5 M Is this ok [y/N]: y
Make sure the git package comes from EPEL and not RPMForge. If it comes from RPMForge, then, install yum-priorities:
> yum install priorities
Make sure that yum-priorities is enabled by editing the /etc/yum/pluginconf.d/priorities.conf file, and ensuring that it contains the following lines:
[main] enabled=1
Add a priority=3 line in the /etc/yum.repos.d/rpmforge.repo
Add a priority=1 lines in each of the three repo sections in the /etc/yum.repos.d/elrepo.repo
Then, do the “yum install git”