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
25854
votes
105 answers

How do I undo the most recent local commits in Git?

I accidentally committed the wrong files to Git, but didn't push the commit to the server yet. How do I undo those commits from the local repository?
Hamza Yerlikaya
  • 49,047
  • 44
  • 147
  • 241
20257
votes
41 answers

How do I delete a Git branch locally and remotely?

Failed Attempts to Delete a Remote Branch: $ git branch -d remotes/origin/bugfix error: branch 'remotes/origin/bugfix' not found. $ git branch -d origin/bugfix error: branch 'origin/bugfix' not found. $ git branch -rd origin/bugfix Deleted remote…
Matthew Rankin
  • 457,139
  • 39
  • 126
  • 163
13671
votes
37 answers

What is the difference between 'git pull' and 'git fetch'?

What are the differences between git pull and git fetch?
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
11359
votes
39 answers

How do I rename a local Git branch?

How do I rename a local branch which has not yet been pushed to a remote repository? Related: Rename master branch for both local and remote Git repositories How do I rename both a Git local and remote branch name?
Forrest
  • 122,703
  • 20
  • 73
  • 107
11151
votes
38 answers

How do I undo 'git add' before commit?

I mistakenly added files to Git using the command: git add myfile.txt I have not yet run git commit. How do I undo this so that these changes will not be included in the commit?
oz10
  • 153,307
  • 27
  • 93
  • 128
9414
votes
52 answers

How do I force "git pull" to overwrite local files?

How do I force an overwrite of local files on a git pull? My local repository contains a file of the same filename as on the server. error: Untracked working tree file 'example.txt' would be overwritten by merge
Jakub Troszok
  • 99,267
  • 11
  • 41
  • 53
8468
votes
43 answers

How do I check out a remote Git branch?

Somebody pushed a branch called test with git push origin test to a shared repository. I can see the branch with git branch -r. How do I check out the remote test branch? I've tried: git checkout test, which does nothing git checkout origin/test…
Juri Glass
  • 88,173
  • 8
  • 33
  • 46
8004
votes
41 answers

How do I remove local (untracked) files from the current Git working tree?

How do I delete untracked local files from the current working tree?
readonly
  • 343,444
  • 107
  • 203
  • 205
7951
votes
33 answers

How do I make Git forget about a file that was tracked, but is now in .gitignore?

I put a file that was previously being tracked by Git onto the .gitignore list. However, the file still shows up in git status after it is edited. How do I force Git to completely forget the file?
Ivan
  • 97,549
  • 17
  • 50
  • 58
7650
votes
27 answers

How to modify existing, unpushed commit messages?

I wrote the wrong thing in a commit message. How can I change the message? The commit has not been pushed yet.
Laurie Young
  • 136,234
  • 13
  • 47
  • 54
7611
votes
41 answers

How do I revert a Git repository to a previous commit?

How do I revert from my current state to a snapshot made on a certain commit? If I do git log, then I get the following output: $ git log commit a867b4af366350be2e7c21b8de9cc6504678a61b` Author: Me Date: Thu Nov 4 18:59:41 2010…
Crazy Serb
  • 76,330
  • 8
  • 35
  • 47
6402
votes
22 answers

Move the most recent commit(s) to a new branch with Git

How do I move my recent commits on master to a new branch, and reset master to before those commits were made? e.g. From this: master A - B - C - D - E To this: newbranch C - D - E / master A - B
Mark A. Nicolosi
  • 82,413
  • 11
  • 44
  • 46
6156
votes
41 answers

How do I discard unstaged changes in Git?

How do I discard changes in my working copy that are not in the index?
readonly
  • 343,444
  • 107
  • 203
  • 205
6037
votes
34 answers

How do I 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…
Bite code
  • 578,959
  • 113
  • 301
  • 329
5639
votes
36 answers

How do I reset or revert a file to a specific revision?

How do I revert a modified file to its previous revision at a specific commit hash (which I determined via git log and git diff)?
Hates_
  • 66,613
  • 6
  • 32
  • 37
1
2 3
99 100