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
1580
votes
18 answers

How can I revert multiple Git commits?

I have a Git repository that looks like this: A <- B <- C <- D <- HEAD I want the head of the branch to point to A, i.e., I want B, C, D, and HEAD to disappear and I want head to be synonymous with A. It sounds like I can either try to rebase…
Bill
  • 44,502
  • 24
  • 122
  • 213
1532
votes
49 answers

Message "Support for password authentication was removed."

I got this error on my console when I tried to use git pull: remote: Support for password authentication was removed on August 13, 2021. remote: Please see…
Daemes
  • 14,239
  • 3
  • 6
  • 13
1527
votes
9 answers

Difference between git stash pop and git stash apply

I've been using git stash pop for quite some time. I recently found out about the git stash apply command. When I tried it out, it seemed to work the same as git stash pop. What is the difference between git stash pop and git stash apply?
Sandeep Raju Prabhakar
  • 18,652
  • 8
  • 35
  • 44
1526
votes
9 answers

Find when a file was deleted in Git

I have a Git repository with n commits. I have a file that I need, and that used to be in the repository, and that I suddenly look for and think "Oh! Where'd that file go?" Is there a (series of) Git command(s) that will tell me that "file…
JohnMetta
  • 18,782
  • 5
  • 31
  • 57
1521
votes
12 answers

Default behavior of "git push" without a branch specified

I use the following command to push to my remote branch: git push origin sandbox If I say git push origin does that push changes in my other branches too, or does it only update my current branch? I have three branches: master, production and…
Debajit
  • 46,327
  • 33
  • 91
  • 100
1519
votes
24 answers

Can I recover a branch after its deletion in Git?

If I run git branch -d XYZ, is there a way to recover the branch? Is there a way to go back as if I didn't run the delete branch command?
prosseek
  • 182,215
  • 215
  • 566
  • 871
1515
votes
20 answers

Changing git commit message after push (given that no one pulled from remote)

I have made a git commit and subsequent push. I would like to change the commit message. If I understand correctly, this is not advisable because someone might have pulled from the remote repository before I make such changes. What if I know that no…
K_U
  • 15,832
  • 8
  • 26
  • 29
1505
votes
20 answers

Ignoring directories in Git repositories on Windows

How can I ignore directories or folders in Git using msysgit on Windows?
sf.
  • 24,512
  • 13
  • 53
  • 58
1482
votes
11 answers

How do you rename a Git tag?

Today I was looking through the logs for a project and realized that I fat fingered a tag name some time ago. Is there some way to rename the tag? Google hasn't turned up anything useful. I realize I could check out the tagged version and make a new…
Brandon Fosdick
  • 15,673
  • 4
  • 21
  • 20
1476
votes
7 answers

How do I delete unpushed git commits?

I accidentally committed to the wrong branch. How do I delete that commit?
NullVoxPopuli
  • 61,906
  • 73
  • 206
  • 352
1475
votes
20 answers

How do I rename both a Git local and remote branch name?

I have a local branch master that points to a remote branch origin/regacy (oops, typo!). How do I rename the remote branch to origin/legacy or origin/master? I tried: git remote rename regacy legacy But this gave an error: error : Could not…
JayD
  • 15,483
  • 5
  • 15
  • 14
1472
votes
10 answers

Create a tag in a GitHub repository

I have a repository in GitHub and I need to tag it. I tagged in a shell, but on GitHub, it is not showing up. Do I have to do anything else? The command I used in the shell is: git tag 2.0 And now when I type git tag it shows: 2.0 So it seems…
Tanel Tammik
  • 15,489
  • 3
  • 22
  • 31
1463
votes
16 answers

Using Git with Visual Studio

As a long-time Visual SourceSafe user (and hater) I was discussing switching to SVN with a colleague; he suggested using Git instead. Since, apparently, it can be used as peer-to-peer without a central server (we are a 3-developer team). I have not…
Herb Caudill
  • 50,043
  • 39
  • 124
  • 173
1463
votes
17 answers

How to cherry-pick multiple commits

I have two branches. Commit a is the head of one, while the other has b, c, d, e and f on top of a. I want to move c, d, e and f to first branch without commit b. Using cherry pick it is easy: checkout first branch cherry-pick one by one c to f and…
tig
  • 25,841
  • 10
  • 64
  • 96
1451
votes
16 answers

Ignoring any 'bin' directory on a git project

I have a directory structure like this: .git/ .gitignore main/ ... tools/ ... ... Inside main and tools, and any other directory, at any level, there can be a 'bin' directory, which I want to ignore (and I want to ignore everything under it…
Ben Hymers
  • 25,586
  • 16
  • 59
  • 84