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
1278
votes
7 answers

How to exit git log or git diff

I'm trying to learn Git with the help of Git Immersion. There's one thing that frustrates me whenever I use git log or git diff: I can't figure out what to do next when I encounter this (END) word. I can't type any commands, and I end up closing…
Wern Ancheta
  • 22,397
  • 38
  • 100
  • 139
1276
votes
16 answers

How do I provide a username and password when running "git clone git@remote.git"?

I know how to include a username and password in a https Git URL like this: git clone https://username:password@host But I'd like to know how to provide a username and password to an SSH remote like this: git clone git@host.git I've tried like…
coordinate
  • 15,224
  • 6
  • 24
  • 24
1275
votes
8 answers

How to tag an older commit in Git?

We are new to git, and I want to set a tag at the beginning of our repository. Our production code is the same as the beginning repository, but we've made commits since then. A tag at the beginning would allow us to "roll back" production to a…
hogsolo
  • 13,565
  • 6
  • 24
  • 25
1272
votes
3 answers

How to list branches that contain a given commit?

How can I query git to find out which branches contain a given commit? gitk will usually list the branches, unless there are too many, in which case it just says "many (38)" or something like that. I need to know the full list, or at least whether…
Andrew Arnott
  • 80,040
  • 26
  • 132
  • 171
1247
votes
16 answers

git undo all uncommitted or unsaved changes

I'm trying to undo all changes since my last commit. I tried git reset --hard and git reset --hard HEAD after viewing this post. I responds with head is now at 18c3773... but when I look at my local source all the files are still there. What am I…
Antarr Byrd
  • 24,863
  • 33
  • 100
  • 188
1233
votes
13 answers

Global Git ignore

I want to set up Git to globally ignore certain files. I have added a .gitignore file to my home directory (/Users/me/) and I have added the following line to it: *.tmproj But it is not ignoring this type of files, any idea what I am doing wrong?
Mild Fuzz
  • 29,463
  • 31
  • 100
  • 148
1232
votes
2 answers

How do I use 'git reset --hard HEAD' to revert to a previous commit?

I know that Git tracks changes I make to my application, and holds on to them until I commit the changes. To revert to a previous commit, I used: $ git reset --hard HEAD HEAD is now at 820f417 micro How do I then revert the files on my hard drive…
Brian McDonough
  • 13,829
  • 4
  • 19
  • 23
1231
votes
13 answers

How to have 'git log' show filenames like 'svn log -v'

SVN's log has a "-v" mode that outputs filenames of files changed in each commit, like so: jes5199$ svn log -v ------------------------------------------------------------------------ r1 | jes5199 | 2007-01-03 14:39:41 -0800 (Wed, 03 Jan 2007) | 1…
jes5199
  • 18,324
  • 12
  • 36
  • 40
1224
votes
14 answers

How can I revert uncommitted changes including files and folders?

Is there a Git command to revert all uncommitted changes in a working tree and index and to also remove newly created files and folders?
MEM
  • 30,529
  • 42
  • 121
  • 191
1217
votes
6 answers

Git: Create a branch from unstaged/uncommitted changes on master

Context: I'm working on master adding a simple feature. After a few minutes I realize it was not so simple and it should have been better to work into a new branch. This always happens to me and I have no idea how to switch to another branch and…
knoopx
  • 17,089
  • 7
  • 36
  • 41
1211
votes
25 answers

Git replacing LF with CRLF

On a Windows machine, I added some files using git add. I got warnings saying: LF will be replaced by CRLF What are the ramifications of this conversion?
mrblah
  • 99,669
  • 140
  • 310
  • 420
1208
votes
25 answers

Find out which remote branch a local branch is tracking

See also: How can I see which Git branches are tracking which remote / upstream branch? How can I find out which remote branch a local branch is tracking? Do I need to parse git config output, or is there a command that would do this for me?
readonly
  • 343,444
  • 107
  • 203
  • 205
1197
votes
13 answers

How to search a Git repository by commit message?

I checked some source code into GIT with the commit message "Build 0051". However, I can't seem to find that source code any more - how do I extract this source from the GIT repository, using the command line? Update Checked in versions 0043, 0044,…
Contango
  • 76,540
  • 58
  • 260
  • 305
1195
votes
33 answers

How can I deal with this Git warning? "Pulling without specifying how to reconcile divergent branches is discouraged"

After a git pull origin master, I get the following message: warning: Pulling without specifying how to reconcile divergent branches is discouraged. You can squelch this message by running one of the following commands sometime before your next…
Davide Casiraghi
  • 15,591
  • 9
  • 34
  • 56
1192
votes
6 answers

Create Git branch with current changes

I started working on my master branch thinking that my task would be easy. After a while I realized it would take more work and I want to do all this work in a new branch. How can I create a new branch and take all these changes with me without…
willcodejavaforfood
  • 43,223
  • 17
  • 81
  • 111