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
183
votes
4 answers

Get all git commits since last tag

When I'm going to tag a commit, I need to know what changed since the last tagged commit. Eg: a87a6sdf87a6d4 Some new feature a87a6sdf87a6d3 Some bug fix a87a6sdf87a6d2 Some comments added a87a6sdf87a6d1 Some merge <- v1.4.0 In this example I would…
ChocoDeveloper
  • 14,160
  • 26
  • 79
  • 117
182
votes
6 answers

git replace local version with remote version

How can I tell git to ignore my local file and take the one from my remote branch without trying to merge and causing conflicts?
ryudice
  • 36,476
  • 32
  • 115
  • 163
182
votes
6 answers

Reverting part of a commit with git

I want to revert a particular commit in git. Unfortunately, our organization still uses CVS as a standard, so when I commit back to CVS multiple git commits are rolled into one. In this case I would love to single out the original git commit, but…
skiphoppy
  • 97,646
  • 72
  • 174
  • 218
182
votes
21 answers

Making git auto-commit

I'd like to use git to record all the changes to a file. Is there a way I can turn git 'commit' on to automatically happen every time a file is updated - so there is a new commit for every change to a file? Ideally I'd like my users to not even…
git-noob
  • 5,757
  • 11
  • 34
  • 32
182
votes
4 answers

Git branch diverged after rebase

I have rebased a branch locally which was already pushed. Git is advising that my branch and remote have diverged and that: "and have 109 and 73 different commits each, respectively" Will pushing my branch resolve this - i.e. is this to be expected…
Marty Wallace
  • 34,046
  • 53
  • 137
  • 200
182
votes
11 answers

Python Git Module experiences?

What are people's experiences with any of the Git modules for Python? (I know of GitPython, PyGit, and Dulwich - feel free to mention others if you know of them.) I am writing a program which will have to interact (add, delete, commit) with a Git…
PTBNL
  • 6,042
  • 4
  • 28
  • 34
182
votes
3 answers

Record file copy operation with Git

When I move a file in git using git-mv the status shows that the file has been renamed and even if I alter some portions it still considers to be almost the same thing (which is good because it lets me follow the history of it). When I copy a file…
Hexdoll
  • 2,006
  • 2
  • 15
  • 9
181
votes
1 answer

How can I have linked dependencies in a git repo?

In my scripts, I often use libraries (mine or others') that have their own repos. I don't want to duplicate those in my repo and get stuck with updating them every time a new version comes out. However, when somebody clones the repo, it should…
Lea Verou
  • 23,618
  • 9
  • 46
  • 48
181
votes
3 answers

"git rm --cached x" vs "git reset head --​ x"?

GitRef.org - Basic: git rm will remove entries from the staging area. This is a bit different from git reset HEAD which "unstages" files. By "unstage" I mean it reverts the staging area to what was there before we started modifying…
Pacerier
  • 86,231
  • 106
  • 366
  • 634
181
votes
4 answers

How do I undo a checkout in git?

I just checked out an earlier commit from my local git repo. I haven't made any changes to it, I was just looking at it. Now I want to go back to my latest commit - how do I do that? The exact command I used to check it out: git checkout…
Yuval Karmi
  • 26,277
  • 39
  • 124
  • 175
181
votes
12 answers

Change the location of the ~ directory in a Windows install of Git Bash

I am not even sure I am asking the right question. Let me explain my situation: This is about Git on Windows 7. My company sets up the Windows user directory on a network drive, not on the local hard drive (for backup and other purposes beyond the…
PEWColina
  • 2,014
  • 2
  • 13
  • 16
181
votes
11 answers

Delete local Git branches after deleting them on the remote repo

I want to have my local and remote repositories always in sync in terms of branches. After a Pull Request review on GitHub, I merge and remove my branch there (remote). How could I fetch this information in my local repository and get Git to remove…
sf89
  • 5,088
  • 7
  • 24
  • 27
180
votes
4 answers

Show history of a file?

Possible Duplicate: View the change history of a file using Git versioning Sometimes I want to step through the history of a particular file. In the past I used P4V and this was very quick and intuitive. Right click on a file and select…
Chris
  • 6,076
  • 11
  • 48
  • 62
180
votes
7 answers

How can I find out what version of git I'm running?

I'm trying to follow some tutorials to learn how to use Git but some of the instructions are for specific versions. Is there a command that I can use find out what version I have installed?
Paul Sheldrake
  • 7,505
  • 10
  • 38
  • 50
180
votes
6 answers

Forking from GitHub to Bitbucket

I'm working on a project based on CakePHP, that's hosted on GitHub. My project is being hosted on Bitbucket. Both of them use git. Basically I'd like to create a ‘fork’ (I don't know if I'm using the right terms, since I'm new to git) of CakePHP in…
entropid
  • 6,130
  • 5
  • 32
  • 45