Tag Info

Hot answers tagged

52

I have $HOME under git. The first line of my .gitignore file is /* The rest are patterns to not ignore using the ! modifier. This first line means the default is to ignore all files in my home directory. Those files that I want to version control go into .gitignore like this: !/.gitignore !/.profile [...] A trickier pattern I have is: !/.ssh /.ssh/* ...


28

You probably want to use git config --global color.ui auto The auto part says that git will only try and use color on terminals that support it, and you will not get ansi sequences if you redirect output of git commands to a file for example. The color.ui is a meta configuration that includes all the various color.* configurations available with git ...


26

You can create a section [color] in your ~/.gitconfig with e.g. the following content [color] diff = auto status = auto branch = auto interactive = auto ui = true pager = true You can also fine control what you want to have coloured in what way, e.g. [color "status"] added = green changed = red bold untracked = magenta bold [color ...


25

One obvious answer is etckeeper by Joey Hess of Debian, which manages files under /etc using version control. It supports subversion, git and mercurial.


24

Not a direct answer to your question (since aliases can only be one word), but you should be using git-config instead: git config --global alias.civ commit -v This creates a git alias so that git civ runs git commit -v. Unfortunately, AFAIK there is no way to override existing git commands with aliases. However, you can always pick a suitable alias name ...


23

You could just use git rm --cached notes.txt. This will keep the file but remove it from the index.


22

Since you're using CentOS 5, the default package manager is yum, not apt-get. To install a program using it, you'd normally use the following command: $ sudo yum install <packagename> However, when trying to install git this way, you'll encounter the following error on CentOS 5: $ sudo yum install git Setting up Install Process Parsing package ...


18

What I do (with the same objectives) is to put my configuration files in a subdirectory ~/lib and have symbolic links in my home directory, e.g., .emacs -> lib/emacs/dot.emacs. I only keep configuration files that I wrote explicitly under version control; my home directory contains plently of automatically-created dot files that are not under version ...


17

Add the following to your ~/.ssh/config file: Host github.com StrictHostKeyChecking no Anything using the open-ssh client to establish a remote shell (with the git client does) should skip the key checks to github.com. This is actually a bad idea since any form of skipping the checks (whether you automatically hit yes or skip the check in the first ...


16

You're seeing the escape sequences that tell the terminal to change colors displayed with the escape character shown as ESC, whereas the desired behavior would be that the escape sequences have their intended effect. Commands such as git diff and git log pipe their output into a pager, less by default. Git tries to tell less to allow control characters to ...


14

A nice alternative is SmartGit. It has some very similar features to SourceTree and has built in 3-column conflict resoluvtion, visual logs, pulling, pushing, merging, syncing, tagging and all things git :)


13

You have several options: Either wait until the version you need is present in the repository you use. Compile your own version and create a deb. Find a repository that provides the version you need for your version of your distribution(e.g. Git PPA). If you don't need any particular feature from the newer version, stay with the old one. If a never ...


12

You're talking about a command that includes a space, but here the command is git and there's no space in there. To call a git commit command, you'd need to write it git\ commit ... 'git commit' ... "git commit" ... Generally commands don't have space in their names for that reason that it is cumbersome to call them in a shell, so I don't think you'll ...


12

The -- is commonly used in command to indicate the end of options. This is useful if your filename begins with a "-" or your input is unknown. Here is an example of its use: git diff --stat -- --file1 --file2 --file1 is treated as a filename rather than another option.


12

See the Content Limitations section of the git Wiki: git does not track file ownership, group membership, doesn't track most permission bits, ACLs, access and modification times, etc. Git tracks contents, and doesn't care much about pretty much everything else.


11

There's no way to express this regular expression with the patterns that gitignore supports. The problem is not the lack of capture groups (in fact, you are not using capture groups as such), the problem is the lack of a | operator. You need to break this into four lines. BigState-[0-9]*.csv SmallState-[0-9]*.csv BigCity-[0-9]*.csv SmallCity-[0-9]*.csv ...


10

Have a look first at git help archive. archive is a git command that allows to make archives containing only git tracked files. Probably what you are looking for. One example listed at the end of the man page: git archive --format=tar --prefix=git-1.4.0/ v1.4.0 | gzip >git-1.4.0.tar.gz


9

For diff, there's git diff --ignore-space-at-eol, which should be good enough. For diff and blame, you can ignore all whitespace changes with -w: git diff -w, git blame -w. For git apply and git rebase, the documentation mentions --ignore-whitespace. For merge, it looks like you need to use an external merge tool. You can use this wrapper script ...


9

What you are asking for is a "git shell". There appears to be one out there by the name git-sh. There isn't a generalized solution that I know of, but git is not the only program with a custom shell just for running it's own commands. Similar examples might be mysql, telnet, ftp, etc. There are actually quite a number of programs that do have their own ...


9

See this related stack overflow answer - http://stackoverflow.com/questions/2927672/how-can-i-get-git-status-to-always-use-short-format It looks like the best option would be making an alias, so you could type git s to get the short listing instead of git status --short and then just use git status for the --verbose listing. git config --global alias.s ...


9

As mentioned on LWN, the easiest is: git describe --contains f3a1ef9cee4812e2d08c855eb373f0d83433e34c If you don't want a local clone, gitweb's "plain" formatted commit contains the same info in the X-Git-Tag header. Unfortunately kernel.org switched over to cgit which apparently does not disclose this information. Previously it was possible to find it ...


9

I wouldn't want my entire home directory checked into version control simply because it means every subdirectory I go into would have the version-control context of my home dir. Commands like git checkout would have an actual action in that case, causing issues if I accidentally run something from the wrong directory, whether that something is git itself or ...


8

I have found no way to configure git at this fourth level. The only solution seems to be per-command configuration value over-rides using git -c key=value. My current hack solution is to define a shell function that serves as a wrapper for git. When called, it passes the arguments on to the system git command, but not before checking on the present working ...


8

Add source /usr/share/git/completion/git-completion.bash to your ~/.bashrc. References Arch Linux Wiki


8

Naive solution: git rev-list --all | xargs -n1 git ls-tree --full-name -r --name-only | sort -u This lists all commits, then uses that to list all files in every commit. sort deduplicates. Only works for small-ish repos though as it takes a long time. A better solution would be to use libgit2 to do the same, should be faster but requires some ...


8

Either use diff -u file1 file2 or git diff branch/commit1 branch/commit2 More on git diff at https://www.kernel.org/pub/software/scm/git/docs/git-diff.html I am not aware of any --git option however for diff and the man page doesn't show it.


7

It might make sense to temporarily exclude a package from installation if the available version is known to be buggy, though this would rarely occur on a server where one generally installs distributions that don't update often except for bug fixes. A reason that comes to mind for excluding perl specifically is if there is a separate installation of perl, ...


7

If you want the archive to include the files tracked by git, but not the git repository itself or any generated or otherwise untracked file, then use git archive. If you specifically want to exclude .git but include everything else, under Linux or FreeBSD or OSX or Cygwin, tar has a simple option to exclude a directory: tar -c --exclude .git -f - foo | ...


7

Aliases are internal to each of your current shell environments - they are expanded by the currently running shell (bash in your case), so they only have effect on what you execute by typing/pasting in your terminal. You have at least two options here: create a wrapper script named vii that will execute vim -c 'startinsert' and put it preferably in ...


7

As always, you should read a command's manpage to find out how it interprets its arguments. -- is commonly used to indicate the end of the command options. This is especially useful if you want to pass a filename or other argument that begins with -. It's also a good idea to use it before wildcards that might expand to a filename beginning with a hyphen. ...



Only top voted, non community-wiki answers of a minimum length are eligible