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

What are some examples of commonly used practices for naming git branches?

I've been using a local git repository interacting with my group's CVS repository for several months, now. I've made an almost neurotic number of branches, most of which have thankfully merged back into my trunk. But naming is starting to become…
skiphoppy
  • 97,646
  • 72
  • 174
  • 218
1354
votes
8 answers

How to uncommit my last commit in Git

How can I uncommit my last commit in git? Is it git reset --hard HEAD or git reset --hard HEAD^ ?
richard
  • 13,881
  • 3
  • 18
  • 9
1352
votes
11 answers

Git merge hotfix branch into feature branch

Let’s say we have the following situation in Git: A created repository: mkdir GitTest2 cd GitTest2 git init Some modifications in the master take place and get committed: echo "On Master" > file git commit -a -m "Initial commit" Feature1 branched…
theomega
  • 31,591
  • 21
  • 89
  • 127
1351
votes
15 answers

How can I merge two commits into one if I already started rebase?

I am trying to merge 2 commits into 1, so I followed “squashing commits with rebase” from git ready. I ran git rebase --interactive HEAD~2 In the resulting editor, I change pick to squash and then save-quit, but the rebase fails with the…
michael
  • 106,540
  • 116
  • 246
  • 346
1343
votes
13 answers

git: undo all working dir changes including new files

How to delete all changes from working directory including new untracked files. I know that git checkout -f does that, but it doesn't delete new untracked files created since last commit. Does anybody have an idea how to do that?
Aler
  • 15,097
  • 6
  • 23
  • 26
1321
votes
8 answers

How do I copy a version of a single file from one Git branch to another?

I've got two branches that are fully merged together. However, after the merge is done, I realise that one file has been messed up by the merge (someone else did an auto-format, gah), and it would just be easier to change to the new version in the…
madlep
  • 47,370
  • 7
  • 42
  • 53
1313
votes
9 answers

What effect does the `--no-ff` flag have for `git merge`?

Using gitk log, I could not spot a difference between the effect of git merge and git merge --no-ff. How can I observe the difference (with a git command or some tool)?
user1162226
  • 13,223
  • 3
  • 14
  • 8
1311
votes
13 answers

Git push rejected after feature branch rebase

OK, I thought this was a simple git scenario, what am I missing? I have a master branch and a feature branch. I do some work on master, some on feature, and then some more on master. I end up with something like this (lexicographic order implies the…
Yuval Adam
  • 161,610
  • 92
  • 305
  • 395
1310
votes
11 answers

How to merge a specific commit in Git

I have forked a branch from a repository in GitHub and committed something specific to me. Now I found the original repository had a good feature which was at HEAD. I want to merge it only without previous commits. What should I do? I know how to…
netawater
  • 15,214
  • 4
  • 24
  • 21
1303
votes
20 answers

master branch and 'origin/master' have diverged, how to 'undiverge' branches'?

Somehow my master and my origin/master branch have diverged. I actually don't want them to diverge. How can I view these differences and merge them?
Frank
  • 18,432
  • 9
  • 30
  • 30
1303
votes
19 answers

Where is the global git config data stored?

When using git config --global to set things up, to which file will it write? Example: git config --global core.editor "blah" I can't find it at these places: C:\Program Files\Git\etc\gitconfig C:\myapp\.git\config I have not set an ENV? My Git…
Ian Vaughan
  • 20,211
  • 13
  • 59
  • 79
1302
votes
27 answers

What is HEAD in Git?

You see the Git documentation saying things like The branch must be fully merged in HEAD. But what is Git HEAD exactly?
bobobobo
  • 64,917
  • 62
  • 258
  • 363
1291
votes
39 answers

How to prune local tracking branches that do not exist on remote anymore?

With git remote prune origin I can remove the local branches that are not on the remote any more. But I also want to remove local branches that were created from those remote branches (a check if they are unmerged would be nice). How can I do this?
Alex
  • 32,506
  • 16
  • 106
  • 171
1287
votes
22 answers

.gitignore for Visual Studio Projects and Solutions

Which files should I include in .gitignore when using Git in conjunction with Visual Studio Solutions (.sln) and Projects?
Martin Suchanek
  • 3,006
  • 6
  • 31
  • 31
1285
votes
8 answers

Create a git patch from the uncommitted changes in the current working directory

Say I have uncommitted changes in my working directory. How can I make a patch from those without having to create a commit?
vrish88
  • 20,047
  • 8
  • 38
  • 56