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
143
votes
5 answers

How to remove commits from a pull request

I did a pull request but after that I made some commits to the project locally which ended polluting my pull request, I tried to remove it but without any luck. I found some similar questions on StackOverflow but I can't apply what's in there. It's…
humazed
  • 66,202
  • 30
  • 86
  • 124
143
votes
7 answers

In Git, how can I write the current commit hash to a file in the same commit

I'm trying to do a fancy stuff here with Git hooks, but I don't really know how to do it (or if it's possible). What I need to do is: in every commit I want to take its hash and then update a file in the commit with this hash. Any ideas?
Felipe Kamakura
  • 2,454
  • 3
  • 16
  • 12
143
votes
4 answers

Github: readonly access to a private repo

I am developing some private projects on Github, and I would like to add nightly cronjobs to my deployments servers to pull the latest version from github. I am currently doing this by generating keypairs on every deployment server and adding the…
Jeroen
  • 28,942
  • 33
  • 116
  • 190
143
votes
4 answers

What is a git topic branch?

What is a git topic branch? Does it differ from an ordinary branch in some way? Are there any branches that are not topic branches?
skiphoppy
  • 83,104
  • 64
  • 169
  • 214
143
votes
3 answers

What is the purpose of `text=auto` in `.gitattributes` file?

Mostly .gitattributes file has * text=auto. What is the purpose of text=auto in that file?
Fizer Khan
  • 71,869
  • 26
  • 133
  • 149
143
votes
2 answers

In a git merge conflict, what are the BACKUP, BASE, LOCAL, and REMOTE files that are generated?

I assume the LOCAL and REMOTE files are just what their name suggests, but what are BASE and BACKUP for?
filler003
  • 1,539
  • 2
  • 10
  • 8
143
votes
14 answers

Heroku 'Permission denied (publickey) fatal: Could not read from remote repository' woes

I've searched around for many hours on end looking to a solution to my seemingly easy-to-fix problem. It's not that my search turned up nothing, it's that my search turned up so many different solutions -none of which have worked. Anyways, I am…
thebradbain
  • 3,069
  • 4
  • 14
  • 17
143
votes
6 answers

How to get commit history for just one branch?

Let's say I created a new branch my_experiment from master and made several commits to my_experiment. If I do a git log when on my_experiment, I see the commits made to this branch, but also the commits made to master before the my_experiments…
Marplesoft
  • 5,330
  • 4
  • 32
  • 46
143
votes
9 answers

Git: Cannot see new remote branch

A colleague pushed a new remote branch to origin/dev/homepage and I cannot see it when I run: $ git branch -r I still see preexisting remote branches. I assume this is because my local remote refs are not up-to-date hence when I ran a git pull…
hybrid9
  • 1,919
  • 4
  • 19
  • 22
143
votes
2 answers

Get all git commits since last tag

When I'm going to tag a commit, I need to know what changed since the last tagged commit. Eg: a87a6sdf87a6d4 Some new feature a87a6sdf87a6d3 Some bug fix a87a6sdf87a6d2 Some comments added a87a6sdf87a6d1 Some merge <- v1.4.0 In this example I would…
ChocoDeveloper
  • 12,930
  • 19
  • 74
  • 113
143
votes
9 answers

When deleting remote git branch "error: unable to push to unqualified destination"

I'm trying to delete a remote git branch with git push origin :my_remote_branch and getting: error: unable to push to unqualified destination: my_remote_branch The destination refspec neither matches an existing ref on the remote nor begins with…
Hugo
  • 11,159
  • 5
  • 27
  • 33
142
votes
9 answers

Git diff output to file preserve coloring

Is it possible to do git diff and save the output to a file with the coloring somehow? I know how to do git diff > filename.rtf - which saves to a file, but I'd like to preserve the coloring.
RoR
  • 13,894
  • 21
  • 65
  • 92
142
votes
6 answers

Git push branch from one remote to another?

I have the following remotes set up: $ git remote korg rorg And the following branches: $ git branch -a * (no branch) remotes/korg/gingerbread remotes/korg/gingerbread-release remotes/korg/honeycomb remotes/korg/honeycomb-mr1-release …
Bjarke Freund-Hansen
  • 23,930
  • 22
  • 87
  • 133
142
votes
4 answers

How do I undo a checkout in git?

I just checked out an earlier commit from my local git repo. I haven't made any changes to it, I was just looking at it. Now I want to go back to my latest commit - how do I do that? The exact command I used to check it out: git checkout…
Yuval Karmi
  • 24,847
  • 38
  • 116
  • 172
142
votes
6 answers

push --force-with-lease by default

I just learned about git push --force-with-lease. It's pretty awesome. But, of course, I don't use force that often, and so I'm worried that I might forget about this nifty feature the next time I need it. Is there a way to configure git so git push…
Dan Fabulich
  • 31,628
  • 35
  • 121
  • 153
1 2 3
99
100