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
3176
votes
30 answers

How do I find and restore a deleted file in a Git repository?

Say I'm in a Git repository. I delete a file and commit that change. I continue working and make some more commits. Then, I discover that I need to restore that file after deleting it. I know I can checkout a file using git checkout --…
avdgaag
  • 41,292
  • 7
  • 29
  • 26
3154
votes
14 answers

I ran into a merge conflict. How do I abort the merge?

I used git pull and had a merge conflict: unmerged: some_file.txt You are in the middle of a conflicted merge. How do I abandon my changes to the file and keep only the pulled changes?
Gwyn Morfey
  • 32,741
  • 6
  • 25
  • 21
3127
votes
19 answers

How do I modify a specific commit?

I have the following commit history: HEAD HEAD~ HEAD~2 HEAD~3 git commit --amend modifies the current HEAD commit. But how do I modify HEAD~3?
Sam Liao
  • 43,637
  • 15
  • 53
  • 61
3080
votes
31 answers

`git fetch` a remote branch

The remote repository contains various branches such as origin/daves_branch: $ git branch -r origin/HEAD -> origin/master origin/daves_branch origin/master How do I switch to daves_branch in the local repository so that it tracks…
David
  • 34,836
  • 11
  • 47
  • 77
3020
votes
9 answers

How do I see the differences between two branches?

How do I see the differences between branches branch_1 and branch_2?
isuruanu
  • 30,273
  • 3
  • 14
  • 4
2981
votes
20 answers

How do I clone a Git repository into a specific folder?

The command git clone git@github.com:whatever creates a directory named whatever containing a Git repository: ./ whatever/ .git I want the contents of the Git repository cloned into my current directory ./ instead: ./ .git
David Smith
  • 38,044
  • 11
  • 44
  • 61
2981
votes
27 answers

How to change the commit author for a single commit?

I want to change the author of one specific commit in the history. It's not the latest commit. Related: How do I change the author and committer name/email for multiple commits?
MicTech
  • 42,457
  • 14
  • 62
  • 79
2974
votes
41 answers

How do I change the author and committer name/email for multiple commits?

How do I change the author for a range of commits?
2815
votes
14 answers

How do I make Git ignore file mode (chmod) changes?

I have a project in which I have to change the mode of files with chmod to 777 while developing, but which should not change in the main repo. Git picks up on chmod -R 777 . and marks all files as changed. Is there a way to make Git ignore mode…
Ro Marcus Westin
  • 28,490
  • 4
  • 18
  • 11
2803
votes
21 answers

Ignore files that have already been committed to a Git repository

I have an already initialized Git repository that I added a .gitignore file to. How can I refresh the file index so the files I want ignored get ignored?
trobrock
  • 46,549
  • 11
  • 40
  • 46
2626
votes
25 answers

How do I get the hash for the current commit in Git?

How do I get the hash of the current commit in Git?
Sardaukar
  • 29,034
  • 5
  • 26
  • 32
2615
votes
15 answers

How to list only the names of files that changed between two commits

I have a bunch of commits in the repository. I want to see a list of files changed between two commits - from SHA1 to SHA2. What command should I use?
Shawn
  • 32,509
  • 17
  • 45
  • 74
2607
votes
1 answer

See what's in a stash without applying it

How do I see what is inside a stash without actually applying it?
Chris Abrams
  • 39,732
  • 19
  • 51
  • 57
2606
votes
24 answers

How do I "git clone" a repo, including its submodules?

How do I clone a git repository so that it also clones its submodules? Running git clone $REPO_URL merely creates empty submodule directories.
user578895
2604
votes
16 answers

How do I safely merge a Git branch into master?

A new branch from master is created, we call it test. There are several developers who either commit to master or create other branches and later merge into master. Let's say work on test is taking several days and you want to continuously keep test…
moe
  • 28,814
  • 4
  • 19
  • 16