Questions tagged [git]

Git is an open source distributed version control system originally designed and written by Linus Torvalds. It is generally used to keep track of source code for software projects. As a DVCS, Git provides powerful help with branching, merging, and distributed development.

Filter by
Sorted by
Tagged with
1123 votes
25 answers

How to tell git which private key to use?

ssh has the -i option to tell which private key file to use when authenticating: -i identity_fileSelects a file from which the identity (private key) for RSA or DSA authentication is read.  The ...
jrdioko's user avatar
  • 12.6k
308 votes
4 answers

How do I reset 'master' to 'origin/master'?

Can I do the following in a simpler way? git checkout origin/master git branch -D master git branch master git checkout master
Lenik's user avatar
  • 18.1k
259 votes
11 answers

Can you GPG sign old commits?

Git now has the ability to sign commits with git commit -S, which is great, but sometimes I forget the flag to commit, and sometimes I mail myself patches which I apply with am, and that command doesn'...
Magnus's user avatar
  • 4,236
236 votes
5 answers

Pull another Git branch without switching

We recently switched from SVN to Git and at the same time put our live systems into version control (instead of local checkout and file copy to live). On the project I'm assigned to we all access the ...
user avatar
232 votes
7 answers

Change git init default branch name

I'm trying to figure out how to make git init use a different default branch name other than master for the first commit, but I can't find a git config for it or anything that'd allow me to do this (e....
SoniEx2's user avatar
  • 2,637
217 votes
5 answers

Git - List all files currently under source control?

Is there a way to list all files currently under source control in git? (Not just those that have been modified).
Anonymous's user avatar
  • 2,601
181 votes
13 answers

How do I ensure Git doesn't ask me for my GitHub username and password?

I am working with a repo on GitHub and everytime I try to push something, it asks for my GitHub username and password. I don't want it doing that. I tried the instructions on setting your email in ...
picardo's user avatar
  • 2,557
156 votes
10 answers

How can I roll back 1 commit?

I have 2 commits that I did not push: $ git status # On branch master # Your branch is ahead of 'faves/master' by 2 commits. How can I roll back my first one (the oldest one), but keep the second ...
n179911's user avatar
  • 3,663
152 votes
9 answers

how to avoid being asked "Enter passphrase for key " when I'm doing ssh operation on a remote host?

I'm ssh into a remote host (linux, fedora) and I want to do ssh operation(git with bitbucket) there. There is ssh-agent running on that machine, $ ps -e|grep sh-agent 2203 ? 00:00:00 ssh-...
lily's user avatar
  • 1,785
151 votes
3 answers

Git on Mac: How to set Nano as the default text editor?

When I'm using Git on Mac and need to do a rebase, the Vim editor kicks in by default. I would prefer Nano – could someone please explain how to reconfigure Git to make it use Nano for rebase?
user avatar
143 votes
6 answers

Is there a way to edit a commit message on GitHub?

Is there a way to edit a commit message after committing and pushing to GitHub? I see that there is a 'add a note' as well as inline commenting, but no actual editing of a commit message. There is ...
Matthew Peters's user avatar
130 votes
5 answers

How to amend the last commit to un-add a file?

I have modified two files a, b in the last commit. But file b should not be commited, what's the workflow to amend this?
Lenik's user avatar
  • 18.1k
128 votes
8 answers

Forward SSH traffic through a middle machine

SSH tunneling is very confusing to me. I am wondering if I can do this in Linux. I have 3 machines.. A. My local machine at home. B. Machine at work that I can SSH into (middle man). C. My desktop ...
user avatar
124 votes
6 answers

Git Bash Here in ConEmu

How do I create a right-click context menu entry to open Git Bash at a given folder within ConEmu? See Git Bash Here in Console2 for the equivalent question for Console2.
Charles Roper's user avatar
111 votes
1 answer

GIT merge master into a branch

I have been developing a new feature on a new branch, and on the side have committed quite a few changes on my master branch. Is it possible to merge the master branch into my new branch to keep it ...
mnml's user avatar
  • 2,021
109 votes
3 answers

How can I change the directory that ssh-keygen outputs to?

I want to run a command like: ssh-keygen -t rsa -b 4096 -C "[email protected]" My understanding is that ssh-keygen outputs to the home directory. I'm working on a networked computer using Git ...
Phlox Midas's user avatar
  • 1,193
105 votes
11 answers

How should I set the PATH variable on my Mac so the Hombrew-installed tools are found?

Trying to set up Homebrew on a new Mac (on previous Macs I would install packages from source). The first package I tried to install was Git: $ brew install git Installation went OK, but which git ...
Meltemi's user avatar
  • 6,877
101 votes
4 answers

Using Multiple SSH Public Keys

I have a personal account and a company account on Unfuddle. On Unfuddle SSH keys can only be used on a single account, so I need to create a seperate SSH key on my laptop for both accounts. I ran ...
Dave Long's user avatar
  • 1,145
100 votes
6 answers

git "ping": check if remote repository exists

I'd like to know whether a remote repository exists. Here's what I came up with: git ls-remote -h "$REPO_URL" &> /dev/null Is there any better way?
Jo Liss's user avatar
  • 4,160
99 votes
7 answers

How to switch git user at terminal?

I am trying to push a project to a remote repository from the command line. From inside my local directory, I hit: $ git push and obtain the following error: remote: Permission to username1/repo....
Mowzer's user avatar
  • 2,209
97 votes
11 answers

How to add the 'tree' command to git-bash in Windows?

I'm using git-bash in Windows 7. I'd like to see a tree of the current directory. However jcollum@DEVELOPER01 ~/Dev/express_coffee $ tree . sh....
jcollum's user avatar
  • 5,023
96 votes
14 answers

How to get git-completion.bash to work on Mac OS X?

I have followed to add git-completion.bash to my /opt/local/etc/bash_completion.d/git-completion and I put PS1='\h:\W$(...
n179911's user avatar
  • 3,663
95 votes
6 answers

How to make git not prompt for passphrase for ssh key?

I'm using git bash and I setup ssh key using ssh-keygen and each time I do something with a repo git ask me for passphrase for /c/Users/jankiewj/.ssh/id_rsa. Is there a way to disable that passphrase. ...
jcubic's user avatar
  • 2,883
89 votes
5 answers

Using Git across multiple systems without network access

I want to use version control but, due to security reasons, the server I'm working on has no internet access: I can only move files on a USB flash drive. Can I still use Git with this setup? Can I ...
Zbyszek Kisły's user avatar
89 votes
1 answer

Terminal Command To Find What Version Of Git I Have Installed?

What is the terminal command to find the version of Git currently installed on my system?
zechdc's user avatar
  • 1,287
78 votes
6 answers

How can I diff binary files in git?

In order to diff binary files in git, I assume I need to set up a difftool. What difftools work? How do you put the parameters in?
Nick Retallack's user avatar
71 votes
6 answers

How to ignore a tracked file in git without deleting it?

My team uses sourcetree as our git client. There is a third-party plugin in our project. It needs several configuration files. These files cannot be generated automatically. They store account name, ...
Liz's user avatar
  • 811
69 votes
2 answers

How to filter commits by author in SourceTree?

In the branch view of SourceTree, I see all the commits. I'd like to filter the commits to show only the ones committed by me/someone. How can I do this? Thanks.
AlikElzin-kilaka's user avatar
68 votes
2 answers

macOS, the command line developer tool missing after updated to Monterey 12.6

My Apple MacBook pro M1 2020 automatically updated to Monterey 12.6 recently. With the update, I have to agree with an Xcode agreement/license. After that, I found both python and git are no longer ...
r0ng's user avatar
  • 835
68 votes
4 answers

How can I push a Git repository to a folder over SSH?

I have a folder called my-project inside which I've done git init, git commit -a, etc. Now I want to push it to an empty folder at /mnt/foo/bar on a remote server. How can I do this? I did try, ...
rich's user avatar
  • 1,211
67 votes
2 answers

How to overwrite a branch in Git with master

I have an old dev branch that is completely outdated. I don't want to remove it but I do want to replace its contents entirely with the master branch. Meaning, I want dev_branch = master I tried: ...
Cornwell's user avatar
  • 906
59 votes
1 answer

How can I merge two branches without losing any files?

I have two branches with the following files in there: branch a: file_a file_b file_c branch b: file_a file_d file_e I want to merge them, so that I get both files from a and b (and files that ...
reox's user avatar
  • 985
59 votes
5 answers

Setting up an encrypted git-repository

Situation Hi, I would like to save data with git, encrypted (on some platform like bitbucket or github). Therefore the question: Question I am looking for different hassle-free ways on: How to set ...
BadAtLaTeX's user avatar
57 votes
1 answer

SSH config - same host but different keys and usernames

I've set up two GitHub accounts, but I can't get ssh keys to work correctly. I've tried various configs. Host github_username1 HostName IdentityFile ~/.ssh/rsa_1 User username1 ...
usr's user avatar
  • 785
54 votes
4 answers

How do I disable password prompts when doing git push/pull?

Every time I want to push and/or pull from the terminal (in Linux) I have to enter a password. How do I remove this so that it pulls and/or pushes without the password?
whirlwin's user avatar
  • 837
53 votes
5 answers

Does Git delete empty folders?

I deleted all files from a directory in my work folder, but the directory itself still exists. After pushing the changes to a remote repository (GitHub) I checked my project and noticed that the ...
vitaliy4us's user avatar
53 votes
5 answers

Bring a local folder to remote git repo

I have a folder with all my files set up for a project. I decided to use git on that folder, so I created on Github an empty repo. Usually the procedure is to clone on my local disk the remote repo, ...
user840718's user avatar
  • 1,063
53 votes
4 answers

How do you install git-filter-repo?

I'm attempting to use git-filter-repo to remove large binaries from my repository. I have not used python before. I installed the latest python by clicking on the downloaded .exe file as that is a ...
CBFT's user avatar
  • 743
52 votes
6 answers

How can I enable colored output for OSX diff?

I need to diff two files (not two versions of the same file, they are however tracked by git, but that is unrelated) and I would like some colored output, how can I achieve that? $ diff file_1 file_2 ...
miphe's user avatar
  • 999
52 votes
3 answers

How can I share a git stash?

Is there a way to share a stash in git? I work on a number of machines, and often want to be able to move my current working state from one to another. I'm looking for a way that I can push/pull a ...
PeterJCLaw's user avatar
  • 2,614
50 votes
4 answers

Cache the password if SSH-keys are forbidden

I have a server which I have to access frequently via ssh, because I compute on it. Now, the computing center explicitly forbids SSH-keys because they are "insecure". They feel that typing my password,...
user2667180's user avatar
50 votes
4 answers

Is a GitHub account required for cloning a repository?

I'm putting together some documentation and don't have access to a non-configured machine to test this myself I'm curious if you need a GitHub account to clone a repository from GitHub to a local ...
user avatar
48 votes
3 answers

How to delete the git reference `refs/original/refs/heads/master`?

What's this in the yellow round box? I've tried git branch -D, git tag -d but none succeeded. So how to delete it?
Lenik's user avatar
  • 18.1k
48 votes
4 answers

Git: How to delete all untracked files?

I'm using Git for version control. Now I want to delete on my local machine all files in the repository that are not tracked. I can use git status to list these files, but how can I delete all of ...
RoflcoptrException's user avatar
47 votes
5 answers

Mark file as “uncommitable” with Git

I want to show off some of my work by uploading them to my GitHub account. However, there are some files that contain passwords, like database connections. Is there a way of marking a file as ...
Adam Carter's user avatar
47 votes
4 answers

Git Bash Here in Console2?

MSysGit installs a context menu item that opens a Git Bash prompt at the currently selected folder; however, this opens a cmd.exe window and I would like it to open in Console2 instead. What ...
Charles Roper's user avatar
46 votes
3 answers

How to view only the unmerged files in git after a merge failure

While merging some of the files failed to merge. git status shows both the successful and failed merges. How to view only the unsuccessful merge files(conflict). Currently i am using the following ...
Talespin_Kit's user avatar
  • 3,291
46 votes
5 answers

How can I discard file change from fugitives status window?

When in the fugitive-plugin status window, accessed using :Git, it's possible to diff changes for a file using D and toggle files for commit using -. Is there any similar shortcut for discarding ...
tidbeck's user avatar
  • 1,545
46 votes
1 answer

git: What does an extra item "origin/HEAD" mean

Following the advice of a friend of mine, I started learning git. I read manual (basic sections) and I think understood most regarding commits, branches, setting backward, forward, etc. but when it ...
Celdor's user avatar
  • 682
44 votes
4 answers

Tmux and ZSH custom prompt : bug with window name

I have customized my ZSH prompt with oh-my-zsh to make it more readable and add information about git if I'm in a repository. Example : bob@inf [~/docs] % bob@inf [~/src/nicest] master % (in a git ...
Adrien Coquio's user avatar

2 3 4 5