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

How do I push a new local branch to a remote Git repository and track it too?

How do I: Create a local branch from another branch (via git branch or git checkout -b). Push the local branch to the remote repository (i.e. publish), but make it trackable so that git pull and git push will work.
Roni Yaniv
  • 57,651
  • 5
  • 19
  • 16
5537
votes
27 answers

Reset local repository branch to be just like remote repository HEAD

How do I reset my local branch to be just like the branch on the remote repository? I tried: git reset --hard HEAD But git status claims I have modified files: On branch master Changes to be committed: (use "git reset HEAD ..." to unstage) …
hap497
  • 154,439
  • 43
  • 83
  • 99
5331
votes
36 answers

How do I resolve merge conflicts in a Git repository?

How do I resolve merge conflicts in my Git repository?
Spoike
  • 119,724
  • 44
  • 140
  • 158
5310
votes
27 answers

How to determine the URL that a local Git repository was originally cloned from

I pulled a project with several forks on GitHub, but forgot which fork it was. How do I determine which fork I pulled?
Tim
  • 53,399
  • 3
  • 19
  • 19
5251
votes
37 answers

How do I add an empty directory to a Git repository?

How do I add an empty directory (that contains no files) to a Git repository?
Laurie Young
  • 136,234
  • 13
  • 47
  • 54
5196
votes
45 answers

How do I squash my last N commits together?

How do I squash my last N commits together into one commit?
markdorison
  • 139,374
  • 27
  • 55
  • 71
4816
votes
35 answers

Undo a Git merge that hasn't been pushed yet

I accidentally ran git merge some_other_branch on my local master branch. I haven't pushed the changes to origin master. How do I undo the merge? After merging, git status says: # On branch master # Your branch is ahead of 'origin/master' by 5…
Matt Huggins
  • 81,398
  • 36
  • 149
  • 218
4732
votes
48 answers

How do I clone all remote branches?

My master and development branches are tracked remotely on GitHub. How do I clone both these branches?
Peter Coulton
  • 54,789
  • 12
  • 54
  • 72
4693
votes
29 answers

How can I delete a remote tag?

How can I delete a Git tag that has already been pushed?
markdorison
  • 139,374
  • 27
  • 55
  • 71
4643
votes
31 answers

How do I update or sync a forked repository on GitHub?

I forked a project, made changes, and created a pull request which was accepted. New commits were later added to the repository. How do I get those commits into my fork?
Lea Hayes
  • 62,536
  • 16
  • 62
  • 111
4430
votes
37 answers

How do I remove a submodule?

How do I remove a Git submodule? Why can't I do git submodule rm module_name?
R. Martinho Fernandes
  • 228,013
  • 71
  • 433
  • 510
4214
votes
37 answers

How do I delete a commit from a branch?

How do I delete a commit from my branch history? Should I use git reset --hard HEAD?
hap497
  • 154,439
  • 43
  • 83
  • 99
4207
votes
19 answers

Undoing a git rebase

How do I easily undo a git rebase? A lengthy manual method is: checkout the commit parent to both of the branches create and checkout a temporary branch cherry-pick all commits by hand reset the faulty rebased branch to point to the temporary…
webmat
  • 58,466
  • 12
  • 54
  • 59
3997
votes
137 answers

Message 'src refspec master does not match any' when pushing commits in Git

I clone my repository with: git clone ssh://xxxxx/xx.git But after I change some files and add and commit them, I want to push them to the server: git add xxx.php git commit -m "TEST" git push origin master But the error I get back is: error: src…
sinoohe
  • 40,334
  • 3
  • 19
  • 16
3990
votes
23 answers

Make an existing Git branch track a remote branch?

I know how to make a new branch that tracks remote branches, but how do I make an existing branch track a remote branch? I know I can just edit the .git/config file, but it seems there should be an easier way.
Pat Notz
  • 208,672
  • 30
  • 90
  • 92