Questions tagged [git]

Git is an open-source distributed version control system (DVCS). Use this tag for questions about Git usage and workflows. Do not use this tag for general programming questions that happen to involve a Git repository. Do not use this tag for GitHub/GitHub Actions questions that do not involve git usage; use [github] or [github-actions] instead. Do not use the [github] tag for Git-related issues just because a repository happens to be hosted on GitHub.

Git is an open-source distributed version control system () with an emphasis on speed. was initially designed and developed by Linus Torvalds for kernel development, now it is maintained by Junio Hamano.

Every Git working directory contains a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server.

The latest stable version is 2.40.0, released on 13 March, 2023.

Characteristics

  • Strong support for non-linear development
  • Distributed development
  • Compatibility with existing systems/protocols
  • Efficient handling of large projects
  • Cryptographic authentication of history
  • Toolkit-based design
  • Pluggable merge strategies
  • Garbage accumulates unless collected
  • Periodic explicit object packing
  • Data Assurance

Data structures

git - data workflow

External Links

Internal Links

Installation/Setup

Working with the code

Tagging, branching, releases, baselines

Git Clients

  • msysgit - Cross platform, included with Git
  • gitk - Cross platform history viewer, included with Git
  • RepoZ - Zero-effort repository hub to track and access local Git repositories for Windows and macOS
  • gitnub - macOS
  • gitx - macOS history viewer
  • smartgit - Cross platform, commercial, beta
  • tig - console GUI for Linux
  • qgit - GUI for Windows, Linux
  • Git Extensions - package for Windows, includes friendly GUI
  • SourceTree - A free Git & Mercurial client for Windows or macOS
  • posh-git - A Windows PowerShell environment for Git
  • TortoiseGit - A Windows Explorer extension with overlay icons representing the file statuses in explorer
  • GitKraken - A fancy, cross-platform Git client
  • GitHub Desktop — A cross-platform client, primarily used for GitHub but works with other hosts

Other Git beginner's references

There are also good guides if you would like to understand Git conceptually or if you would like to compare other revision control software such as subversion.

Free Git hosting

Video Tutorial

Related tags

Chat

The Stack Overflow git chat is useful for coordinating work within this tag, and perhaps occasionally for getting quick help (though no guarantees can be made; attendance is spotty).

150148 questions
180
votes
6 answers

Can I make a user-specific gitignore file?

I want to change the gitignore, but not everyone on the team wants these changes. How can a user have their own specific git ignore file?
asdsadasds
  • 1,803
  • 2
  • 12
  • 4
180
votes
4 answers

How do I reset the git master branch to the upstream branch in a forked repository?

I've completely messed up the master branch of my forked git repo. I want to completely reset the master branch that was pushed to my fork with the contents of the upstream master repo. I have no interest in retaining any master branch changes or…
fossfreedom
  • 2,903
  • 2
  • 19
  • 40
180
votes
17 answers

Remove git mapping in Visual Studio 2015

This question has nothing to do with git itself; rather, it has to do with removing a binding/mapping to a git repository that Visual Studio 2015 (VS2015) has previously seen. Here's a screen shot of the problem: Notice that the remove button is…
Matthew Kraus
  • 6,660
  • 5
  • 24
  • 31
180
votes
10 answers

Git: How to pull a single file from a server repository in Git?

I am working on a site with a server running Git. I am using Git for deployment (not GitHub). This was set up prior to my involvement using a hook method, and I referred to this question and entered the commands below, but it didn't work. How do I…
vsvs
  • 1,975
  • 2
  • 12
  • 14
180
votes
4 answers

git push to specific branch

Even after reading this question: git-push-current-branch, I am still having difficulty figuring out how I should write my git push command. As mentioned in the question link, it's not clear from the documentation. I would like to use my 'real…
code_fodder
  • 15,263
  • 17
  • 90
  • 167
180
votes
9 answers

unable to remove file that really exists - fatal: pathspec ... did not match any files

unable to remove file that really exists - fatal: pathspec ... did not match any files I have a file under git control that simply will not be deleted. The failing command is: $ git rm .idea/workspace.xml fatal: pathspec '.idea/workspace.xml' did…
Matthew Cornell
  • 4,114
  • 3
  • 27
  • 40
180
votes
22 answers

git update-index --assume-unchanged returns "fatal unable to mark file"

I am having the same problem as the OP on this post, but I don't understand the answer marked as correct (I don't see that it explains how to fix the situation) I do this and get this error: $ git update-index --assume-unchanged web.config fatal:…
Karen
  • 2,296
  • 3
  • 18
  • 19
179
votes
1 answer

git submodule tracking latest

We are moving our (huge) project to git and we are thinking about using submodules. Our plan is to have three different heads in the superproject: release, stable, latest The project leads will handle the release and stable branches. They will…
l.thee.a
  • 3,231
  • 6
  • 25
  • 28
179
votes
8 answers

How do you squash commits into one patch with git format-patch?

I've got eight commits on a branch that I'd like to email to some people who aren't git enlightened, yet. So far, everything I do either gives me 8 patch files, or starts giving me patch files for every commit in the branch's history, since the…
skiphoppy
  • 97,646
  • 72
  • 174
  • 218
179
votes
4 answers

git merge: apply changes to code that moved to a different file

I am attempting a pretty beefy git merge maneuver right now. One problem that I am coming across is that I made some changes to some code in my branch, but my colleague moved that code to a new file in his branch. So when I did git merge my_branch…
asmeurer
  • 86,894
  • 26
  • 169
  • 240
179
votes
7 answers

Is there a way to reduce the size of the git folder?

Seems like my project is getting bigger and bigger with every git commit/push. Is there a way to clean up my git folder?
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556
179
votes
7 answers

Git: How to remove file from index without deleting files from any repository

When you use git rm --cached myfile it doesn't delete from the local filesystem, which is the goal. But if you've already versioned and committed the file, pushed it to a central repository, and pulled it into yet another repository before using…
Fletcher Moore
  • 13,558
  • 11
  • 40
  • 58
179
votes
25 answers

There isn't anything to compare. Nothing to compare, branches are entirely different commit histories

I have a CMS theme installed on my machine. I'm tracking changes to it via git and decided to back it up on GitHub so I could share those changes. The theme as provided is also available on GitHub. On my machine I have added this as a remote…
Jack
  • 2,245
  • 2
  • 14
  • 18
179
votes
7 answers

Undo part of unstaged changes in git

How do I undo parts of my unstaged changes in git but keep the rest as unstaged? The way I figured out is: git commit --interactive # Choose the parts I want to delete # Commit the changes git stash git rebase -i master # (I am an ancestor of…
asmeurer
  • 86,894
  • 26
  • 169
  • 240
179
votes
33 answers

GitHub commits aren't recorded in the 'Your Contributions` calendar

I've been making continuous commits to my GitHub repos from my Linux shell and they show up nicely on the website just as they should. The only problem is that "Your Contributions" section doesn't show any recent activity. I have one green square…
Roey Angel
  • 2,055
  • 2
  • 15
  • 9