gitignore across all branches?

久未见 提交于 2019-12-04 18:51:42

问题


Hey I'm trying to get into git, as an emacs user first thing to do is to make sure the ~ and #*# files are ignored by git. Documentation talks about .gitignore which I've been using. However couple of questions remain:

  • gitignore is now checked in and part of a branch. Should .gitignore be checked in and if so, how can i make it easy available across all branches in my repository?
  • is there a way to use the gitignore with git config so gitignore stays constant over all my repos?
  • How can I deal with emacs lock files as #*# is treated as a comment?

I'm on mac ox snow leopard. regards, Jeroen


回答1:


Add this to your $HOME/.gitconfig ;

[core]
    excludesfile = /path/to/your/local/.gitignore

Then it'll be locally available on all your git repositories.




回答2:


If you created the gitignore file before creating the branches, it's obviously available in them. Otherwise you need to merge that file to other branches.

You can define a global ignore file with git config --global core.excludesfile [ignorefile].




回答3:


  • http://cogniton-mind.tumblr.com/post/1423976659/howto-gitignore-for-different-branches
  • You can create a global gitignore

create a ~/.gitignore in your user directory

.DS_Store 
*.pyc 
.svn 

then run: git config --global core.excludesfile ~/.gitignore

  • Emacs files

    \#*#

Since 1.6.2, \ should be supported in .gitignore




回答4:


  1. Check-in the .gitignore file. It is available across all the branches (unless you mess about with it) and keep it up to date with all your exclusions
  2. Use a global gitignore file.
  3. Add this to your gitignore file.

    #
    .#

I've written about the three ways of excluding files here.




回答5:


Simplest way to get that file into all branches would be probably git cherry-pick commit with .gitignore file into those branches



来源:https://stackoverflow.com/questions/4944879/gitignore-across-all-branches

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!