Home Explore Blog CI



git

5th chunk of `Documentation/gitfaq.adoc`
3331bb42a07d773b6d9a2594c74d0ca6bd34905c969855390000000100000fa1
 made and was a valuable
	contribution, but also introduces a new commit that undoes those changes
	because the original had a problem.  The commit message of the revert
	indicates the commit which was reverted and is usually edited to include
	an explanation as to why the revert was made.

[[ignore-tracked-files]]
How do I ignore changes to a tracked file?::
	Git doesn't provide a way to do this.  The reason is that if Git needs
	to overwrite this file, such as during a checkout, it doesn't know
	whether the changes to the file are precious and should be kept, or
	whether they are irrelevant and can safely be destroyed.  Therefore, it
	has to take the safe route and always preserve them.
+
It's tempting to try to use certain features of `git update-index`, namely the
assume-unchanged and skip-worktree bits, but these don't work properly for this
purpose and shouldn't be used this way.
+
If your goal is to modify a configuration file, it can often be helpful to have
a file checked into the repository which is a template or set of defaults which
can then be copied alongside and modified as appropriate.  This second, modified
file is usually ignored to prevent accidentally committing it.

[[files-in-gitignore-are-tracked]]
I asked Git to ignore various files, yet they are still tracked::
	A `gitignore` file ensures that certain file(s) which are not
	tracked by Git remain untracked.  However, sometimes particular
	file(s) may have been tracked before adding them into the
	`.gitignore`, hence they still remain tracked.  To untrack and
	ignore files/patterns, use `git rm --cached <file/pattern>`
	and add a pattern to `.gitignore` that matches the <file>.
	See linkgit:gitignore[5] for details.

[[fetching-and-pulling]]
How do I know if I want to do a fetch or a pull?::
	A fetch stores a copy of the latest changes from the remote
	repository, without modifying the working tree or current branch.
	You can then at your leisure inspect, merge, rebase on top of, or
	ignore the upstream changes.  A pull consists of a fetch followed
	immediately by either a merge or rebase.  See linkgit:git-pull[1].

[[proxy]]
Can I use a proxy with Git?::
	Yes, Git supports the use of proxies.  Git honors the standard `http_proxy`,
	`https_proxy`, and `no_proxy` environment variables commonly used on Unix, and
	it also can be configured with `http.proxy` and similar options for HTTPS (see
	linkgit:git-config[1]).  The `http.proxy` and related options can be
	customized on a per-URL pattern basis.  In addition, Git can in theory
	function normally with transparent proxies that exist on the network.
+
For SSH, Git can support a proxy using OpenSSH's `ProxyCommand`. Commonly used
tools include `netcat` and `socat`.  However, they must be configured not to
exit when seeing EOF on standard input, which usually means that `netcat` will
require `-q` and `socat` will require a timeout with something like `-t 10`.
This is required because the way the Git SSH server knows that no more requests
will be made is an EOF on standard input, but when that happens, the server may
not have yet processed the final request, so dropping the connection at that
point would interrupt that request.
+
An example configuration entry in `~/.ssh/config` with an HTTP proxy might look
like this:
+
----
Host git.example.org
    User git
    ProxyCommand socat -t 10 - PROXY:proxy.example.org:%h:%p,proxyport=8080
----
+
Note that in all cases, for Git to work properly, the proxy must be completely
transparent.  The proxy cannot modify, tamper with, or buffer the connection in
any way, or Git will almost certainly fail to work.  Note that many proxies,
including many TLS middleboxes, Windows antivirus and firewall programs other
than Windows Defender and Windows Firewall, and filtering proxies fail to meet
this standard, and as a result end up breaking Git.  Because of the many
reports of problems and their poor security history, we recommend against the
use of these classes of software and

Title: Git FAQs and Troubleshooting
Summary
This section addresses various common issues and questions in Git, including ignoring changes to tracked files, understanding the difference between fetch and pull, using proxies with Git, and resolving issues with files that are still tracked despite being added to `.gitignore`. It provides explanations, examples, and configuration tips to help users overcome these challenges and use Git effectively.