Questions tagged [git]

Git is an open-source distributed version control system (DVCS). Use this tag for questions related to Git usage and workflows. DO NOT USE the [github] tag for Git-related issues simply because a repository happens to be hosted on GitHub. Also, do not use this tag for general programming questions that happen to involve a Git repository.

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.30.1, released on 8 February, 2021.

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

Clients that are primarily used for GitHub but also support Git

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

Codeschool Git Tutorial - Build a solid foundation in Git
Git Tutorial Playlist - Beginner's Guide for Git

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).

133870 questions
4757
votes
15 answers

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

I want to be able to do the following: Create a local branch based on some other (remote or local) branch (via git branch or git checkout -b) Push the local branch to the remote repository (publish), but make it trackable so git pull and git push…
Roni Yaniv
  • 49,329
  • 5
  • 17
  • 14
4623
votes
36 answers

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

How can I add an empty directory (that contains no files) to a Git repository?
Laurie Young
  • 129,506
  • 13
  • 44
  • 54
4535
votes
26 answers

How can I determine the URL that a local Git repository was originally cloned from?

I pulled a project from GitHub a few days ago. I've since discovered that there are several forks on GitHub, and I neglected to note which one I took originally. How can I determine which of those forks I pulled?
Tim
  • 45,633
  • 3
  • 17
  • 19
4498
votes
28 answers

How to change the URI (URL) for a remote Git repository?

I have a repo (origin) on a USB key that I cloned on my hard drive (local). I moved "origin" to a NAS and successfully tested cloning it from here. I would like to know if I can change the URI of "origin" in the settings of "local" so it will now…
e-satis
  • 515,820
  • 103
  • 283
  • 322
4428
votes
21 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 did: git reset --hard HEAD But when I run a git status, On branch master Changes to be committed: (use "git reset HEAD ..." to unstage) modified: …
hap497
  • 129,793
  • 42
  • 77
  • 91
4370
votes
42 answers

How to clone all remote branches in Git?

I have a master and a development branch, both pushed to GitHub. I've cloned, pulled, and fetched, but I remain unable to get anything other than the master branch back. I'm sure I'm missing something obvious, but I have read the manual and I'm…
Peter Coulton
  • 50,723
  • 11
  • 51
  • 70
4283
votes
33 answers

Undo a Git merge that hasn't been pushed yet

Within my master branch, I did a git merge some-other-branch locally, but never pushed the changes to origin master. I didn't mean to merge, so I'd like to undo it. When doing a git status after my merge, I was getting this message: # On branch…
Matt Huggins
  • 73,807
  • 32
  • 140
  • 214
4188
votes
31 answers

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

I forked a project, applied several fixes and created a pull request which was accepted. A few days later, another change was made by another contributor. So my fork doesn't contain that change. How can I get that change into my fork? Do I need to…
Lea Hayes
  • 56,578
  • 16
  • 55
  • 104
4121
votes
38 answers

Squash my last X commits together using Git

How can I squash my last X commits together into one commit using Git?
markdorison
  • 115,110
  • 27
  • 52
  • 69
3876
votes
24 answers

How to delete a remote tag?

How do you delete a Git tag that has already been pushed?
markdorison
  • 115,110
  • 27
  • 52
  • 69
3790
votes
31 answers

How do I remove a submodule?

How do I remove a Git submodule? By the way, is there a reason I can't simply do git submodule rm whatever ?
R. Martinho Fernandes
  • 209,766
  • 68
  • 412
  • 492
3679
votes
22 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
  • 186,044
  • 29
  • 86
  • 92
3568
votes
33 answers

Delete commits from a branch in Git

I would like to know how to delete a commit. By delete, I mean it is as if I didn't make that commit, and when I do a push in the future, my changes will not push to the remote branch. I read git help, and I think the command I should use is git…
hap497
  • 129,793
  • 42
  • 77
  • 91
3500
votes
18 answers

Undoing a git rebase

Does anybody know how to easily undo a git rebase? The only way that comes to mind is to go at it manually: git checkout the commit parent to both of the branches then create a temp branch from there cherry-pick all commits by hand replace the…
webmat
  • 50,648
  • 12
  • 52
  • 59
3389
votes
7 answers

How do I clone a specific Git branch?

Git clone will behave copying remote current working branch into local. Is there any way to clone a specific branch by myself without switching branches on the remote repository?
Scud
  • 36,193
  • 6
  • 23
  • 18