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
2063
votes
20 answers

How to stop tracking and ignore changes to a file in Git?

I have cloned a project that includes some .csproj files. I don't need/like my local csproj files being tracked by Git (or being brought up when creating a patch), but clearly they are needed in the project. I have added *.csproj to my LOCAL…
Joshua Ball
  • 23,260
  • 6
  • 27
  • 29
2060
votes
12 answers

How can I delete all of my Git stashes at once?

How can I delete all of my Git stashes at once? Specifically I mean, with typing in one command.
Rebekah Waterbury
  • 22,236
  • 5
  • 23
  • 28
2055
votes
17 answers

Make the current Git branch a master branch

I have a repository in Git. I made a branch, then did some changes both to the master and to the branch. Then, tens of commits later, I realized the branch is in much better state than the master, so I want the branch to "become" the master and…
Karel Bílek
  • 36,467
  • 31
  • 94
  • 149
2042
votes
30 answers

How do I fix a Git detached head?

I was doing some work in my repository and noticed a file had local changes. I didn't want them anymore so I deleted the file, thinking I can just checkout a fresh copy. I wanted to do the Git equivalent of svn up . Using git pull didn't seem to…
Daniel
  • 23,365
  • 10
  • 36
  • 34
2028
votes
4 answers

How does Git handle symbolic links?

If I have a file or directory that is a symbolic link and I commit it to a Git repository, what happens to it? I would assume that it leaves it as a symbolic link until the file is deleted and then if you pull the file back from an old version it…
Alex
  • 34,776
  • 10
  • 53
  • 68
2023
votes
15 answers

Undo working copy modifications of one file in Git

After the last commit, I modified a bunch of files in my working copy, but I want to undo the changes to one of those files, as in reset it to the same state as the most recent commit. However, I only want to undo the working copy changes of just…
hasen
  • 161,647
  • 65
  • 194
  • 231
2004
votes
21 answers

How can I remove a commit on GitHub?

I "accidentally" pushed a commit to GitHub. Is it possible to remove this commit? I want to revert my GitHub repository as it was before this commit.
hectorsq
  • 74,396
  • 19
  • 43
  • 46
1972
votes
31 answers

How do I clone a subdirectory only of a Git repository?

I have my Git repository which, at the root, has two sub directories: /finisht /static When this was in SVN, /finisht was checked out in one place, while /static was checked out elsewhere, like so: svn co…
Nick Sergeant
  • 35,843
  • 12
  • 36
  • 44
1967
votes
26 answers

Detach (move) subdirectory into separate Git repository

I have a Git repository which contains a number of subdirectories. Now I have found that one of the subdirectories is unrelated to the other and should be detached to a separate repository. How can I do this while keeping the history of the files…
matli
  • 27,922
  • 6
  • 37
  • 37
1963
votes
14 answers

How to get just one file from another branch

I have a main branch with a file called app.js. I made changes to this file on an experiment branch. I want to apply only the changes made to app.js from experiment onto the main branch.
Nick Vanderbilt
  • 36,724
  • 29
  • 83
  • 106
1955
votes
19 answers

Resolve Git merge conflicts in favor of their changes during a pull

How do I resolve a git merge conflict in favor of pulled changes? I want to remove all conflicting changes from a working tree without having to go through all of the conflicts with git mergetool, while keeping all conflict-free changes. Preferably,…
sanmai
  • 29,083
  • 12
  • 64
  • 76
1943
votes
13 answers

Can I delete a git commit but keep the changes?

In one of my development branches, I made some changes to my codebase. Before I was able to complete the features I was working on, I had to switch my current branch to master to demo some features. But just using a "git checkout master" preserved…
tanookiben
  • 22,575
  • 8
  • 27
  • 25
1939
votes
32 answers

How can I get a list of Git branches, ordered by most recent commit?

I want to get a list of all the branches in a Git repository with the "freshest" branches at the top, where the "freshest" branch is the one that's been committed to most recently (and is, therefore, more likely to be one I want to pay attention…
Joe White
  • 94,807
  • 60
  • 220
  • 330
1928
votes
29 answers

Why do I need to do `--set-upstream` all the time?

I create a new branch in Git: git branch my_branch Push it: git push origin my_branch Now say someone made some changes on the server and I want to pull from origin/my_branch. I do: git pull But I get: You asked me to pull without telling me…
Ram Rachum
  • 84,019
  • 84
  • 236
  • 374
1908
votes
11 answers

How can I view an old version of a file with Git?

Is there a command in Git to see (either dumped to stdout, or in $PAGER or $EDITOR) a particular version of a particular file?
mike
  • 46,876
  • 44
  • 102
  • 112