Skip to main content
Filter by
Sorted by
Tagged with
4499 votes
42 answers
5.7m views

How do I delete a commit from my branch history? Should I use git reset --hard HEAD?
hap497's user avatar
  • 165k
2729 votes
23 answers
1.5m views

If I have an n number of commits, how can I create a branch from the n-3 commit?
dole doug's user avatar
  • 36.4k
2042 votes
14 answers
795k views

I accidentally amended my previous commit. The commit should have been separate to keep history of the changes I made to a particular file. Is there a way to undo that last commit? If I do something ...
Jesper Rønn-Jensen's user avatar
1775 votes
19 answers
1.4m views

I have a Git repository that looks like this: A <- B <- C <- D <- HEAD I want the head of the branch to point to A, i.e., I want B, C, D, and HEAD to disappear and I want head to be ...
Bill's user avatar
  • 46k
1756 votes
21 answers
1.4m views

I have made a git commit and subsequent push. I would like to change the commit message. If I understand correctly, this is not advisable because someone might have pulled from the remote repository ...
K_U's user avatar
  • 18.3k
1244 votes
33 answers
736k views

The answers to How to modify existing, unpushed commits? describe a way to amend previous commit messages that haven't yet been pushed upstream. The new messages inherit the timestamps of the ...
Dhskjlkakdh's user avatar
  • 12.9k
1217 votes
18 answers
497k views

Is there a way to list all commits that changed a specific file?
Daniel's user avatar
  • 12.5k
1140 votes
7 answers
892k views

I have made several commits on different files, but so far I would like to push to my remote repository only a specific commit. Is that possible?
Robert23's user avatar
  • 11.4k
1030 votes
8 answers
420k views

Is there a way to amend a commit without vi (or your $EDITOR) popping up with the option to modify your commit message, but simply reusing the previous message?
Sridhar Sarnobat's user avatar
943 votes
10 answers
632k views

I ran "git status" and listed below are some files that were modified/or under the heading "changes not staged for commit". It also listed some untracked files that I want to ignore (I have a "....
Steve's user avatar
  • 12.5k
889 votes
3 answers
597k views

Sometimes it happens that I make some changes in my working directory, and I realize that these changes should be committed in a branch different to the current one. This usually happens when I want ...
Auron's user avatar
  • 14.4k
786 votes
1 answer
504k views

Possible Duplicate / a more recent/less clear question Branch from a previous commit using Git I have a Git branch called jzbranch and have an old commit id: a9c146a09505837ec03b. How do I create ...
JZ.'s user avatar
  • 22.1k
723 votes
5 answers
375k views

I find a lot of answers on how to reference a GitHub issue in a git comment (using the #xxx notation). I'd like to reference a commit in my comment, generating a link to the commit details page?
LodeRunner's user avatar
  • 8,493
602 votes
12 answers
331k views

Is there a way to edit the log message of a certain revision in Subversion? I accidentally wrote the wrong filename in my commit message which could be confusing later. I've seen How do I edit an ...
Paige Ruten's user avatar
523 votes
14 answers
162k views

Is it possible to see who edited a specific line before the commit reported by git blame, like a history of commits for a given line? For example, I run the following (on the superb uncrustify ...
Aidan Steele's user avatar
  • 11.4k
511 votes
4 answers
419k views

I am fairly new to Github and have come across an amateur-ish problem. I have been asked to do a code review and have been provided with a commit hash, however I have tried looking in Git if I can ...
dopplesoldner's user avatar
507 votes
17 answers
879k views

I was working with a friend on a project, and he edited a bunch of files that shouldn't have been edited. Somehow I merged his work into mine, either when I pulled it, or when I tried to just pick the ...
Joshua Cheek's user avatar
  • 32.1k
489 votes
21 answers
336k views

I'm trying to review a pull request on GitHub to a branch that isn't master. The target branch was behind master and the pull request showed commits from master, so I merged master and pushed it to ...
lobati's user avatar
  • 10.4k
483 votes
2 answers
183k views

I'd like to get the number of commits per author on all branches. I see that git shortlog -s -n Prints a very nice list but it is not counting the commits that are not yet merged from other branches. ...
jabal's user avatar
  • 12.5k
447 votes
5 answers
266k views

The situation: master is at X quickfix1 is at X + 2 commits Such that: o-o-X (master HEAD) \ q1a--q1b (quickfix1 HEAD) Then I started working on quickfix2, but by accident took quickfix1 ...
Alex Yarmula's user avatar
  • 10.7k
422 votes
10 answers
103k views

Git treats lines starting with # (hash, number sign, octothorpe, pound sign) as comment lines when committing. This is very annoying when working with a ticket tracking system, and trying to write the ...
knittl's user avatar
  • 269k
356 votes
22 answers
444k views

I ran a git pull that ended in a conflict. I resolved the conflict and everything is fine now (I used mergetool also). When I commit the resolved file with git commit file.php -m "message" I get the ...
pMan's user avatar
  • 9,248
349 votes
3 answers
161k views

How to switch to specific Git commit without losing all the commits made after it? I want that local files will be changed, but commits' database will remain intact, only the current position pointer ...
Paul's user avatar
  • 26.8k
339 votes
5 answers
91k views

Say I have a file foo.js that was committed some time ago. I would like to simply find the commit where this file was first added. After reading the answers and my own tinkering, this works for me: ...
Zombo's user avatar
  • 1
334 votes
3 answers
626k views

how do i revert all my files on my local copy back to a certain commit? commit 4a155e5b3b4548f5f8139b5210b9bb477fa549de Author: John Doe <[email protected]> Date: Thu Jul 21 20:51:38 2011 ...
David's user avatar
  • 10.8k
321 votes
11 answers
182k views

I am curious about how to remove the first commit in git. What is the revision before committing any thing? Does this revision have a name or tag?
Weihang Jian's user avatar
  • 8,945
304 votes
4 answers
176k views

I'm developing a django app and I'm using pip to manage my requirements. How can I do to install a specific git's commit? In my case I need to install this commit: https://github.com/aladagemre/...
kelwinfc's user avatar
  • 3,411
304 votes
6 answers
56k views

I flubbed up my history and want to do some changes to it. Problem is, I have a commit with two unrelated changes, and this commit is surrounded by some other changes in my local (non-pushed) history. ...
Ben's user avatar
  • 7,800
299 votes
3 answers
197k views

If you want to move a commit to the staging area - that is uncommit it and move all of the changes which were in it into the staging area (effectively putting the branch in the state that it would ...
Jonathan M Davis's user avatar
285 votes
21 answers
715k views

I'm working on a team with a few developers using Git on Bitbucket. We are all working on a dev branch, not pushing to master until a release. One of the developers committed incorrect code that ...
thanos's user avatar
  • 3,371
275 votes
4 answers
617k views

I've only just started to use Git and think it is wonderful, however I'm a little confused over what the merge command does. Let us say we have a working project in the branch "A". I go home ...
dotty's user avatar
  • 41.7k
269 votes
6 answers
250k views

I'm trying to delete the last two commits from one of my GitHub repositories. I've tried as suggested here: git push -f origin HEAD^^:master. It seems that it works, as the last two commits are ...
Ivan Fernandez's user avatar
265 votes
5 answers
171k views

How can I make a new commit and create a new message if no changes are made to files? Is this not possible since the commit's code (SHA ?) will be the same?
d-_-b's user avatar
  • 23.2k
250 votes
9 answers
225k views

I would like to remove selected commit log entries from a linear commit tree, so that the entries do not show in the commit log. My commit tree looks something like: R--A--B--C--D--E--HEAD I would ...
xk0der's user avatar
  • 3,690
244 votes
9 answers
262k views

Is there any way of online editing the commit message in GitHub.com, after submission? From the command line, one can do git commit --amend -m "New commit message" as correctly suggested in ...
PNS's user avatar
  • 20.1k
238 votes
10 answers
90k views

Is there a way to see the date of a commit in github, with day/hour precision? Older commits appear in a "human readable" format, such as "2 years ago" instead of showing the actual date. If it's not ...
loopbackbee's user avatar
  • 23.6k
236 votes
6 answers
241k views

Trying to learn GitHub at the moment and doing this Git essentials tutorial over at nettuts. I'm on the lesson about making commits. The teacher types git commit and it opens VIM as his editor (I'd ...
Leon Gaban's user avatar
  • 39.4k
228 votes
8 answers
145k views

How do I edit or reword a merge commit's message? git commit --amend works if it's the last commit made (HEAD), but what if it comes before HEAD? git rebase -i HEAD~5 doesn't list the merge commits.
ma11hew28's user avatar
  • 128k
227 votes
8 answers
118k views

I'm looking for a counter-part of git commit --amend in Mercurial, i.e. a way to modify the commit which my working copy is linked to. I'm only interested in the last commit, not an arbitrary earlier ...
mstrap's user avatar
  • 17.6k
218 votes
2 answers
138k views

Our project uses Git as the version control system and recently I needed to review someone's commits. How can I see a list of commits made by a specific user?
user285020's user avatar
  • 3,063
209 votes
14 answers
550k views

This will be my first git use. I have added new files ( a lot ) to the folder/project ( git local repository). I went through online tutorials and forums and see i can do git commit -a So I go to the ...
kishore .'s user avatar
  • 2,323
188 votes
8 answers
223k views

This question pertains not only to how to accomplish this task, but to whether doing so is good or bad practice with Git. Consider that locally I do most work on the main branch, but I have created a ...
Todd Hopkinson's user avatar
186 votes
8 answers
148k views

This is mostly a git question. I want to commit my ipython notebooks but gitignore the checkpoints. The repo has multiple folders which each have ipython notebooks, therefore just ignoring a single ...
sapo_cosmico's user avatar
  • 6,582
174 votes
10 answers
229k views

I'm trying to commit some changes as a different user, but i do not have a valid email address, following command is not working for me: git commit --author="john doe" -m "some fix" fatal: No ...
Willem D'Haeseleer's user avatar
171 votes
7 answers
536k views

I am newbie in git and I am working on git. I added some files in git : git add <file1> git add <file2> then I wanted to push that for review, but mistakenly I did git commit so the ...
sam's user avatar
  • 19.3k
169 votes
10 answers
249k views

How can I commit changes without specifying commit message? Why is it required by default?
Nik's user avatar
  • 1,755
164 votes
9 answers
181k views

What is the difference between git add, push and commit? Just a little confused coming from SVN, where "update" will 'add' stuff, and commit does a "push" and will 'add' as well There are all ...
CQM's user avatar
  • 44.6k
158 votes
3 answers
96k views

I want to be able to do this for a script. I'm essentially re-creating the entire version history of some code in Git - it currently uses a different version control system. I need the script to be ...
Carl's user avatar
  • 44.8k
155 votes
5 answers
163k views

OS: Windows I write $ git commit then "# Please enter the commit message" I write some text, like "Form validation added" Press Enter and not commited. Then i press Shift+Enter, Ctrl+Enter, Alt+...
aTei's user avatar
  • 1,854
150 votes
10 answers
208k views

Suppose I have a query: begin tran -- some other sql code And then I forget to commit or roll back. If another client tries to execute a query, what would happen?
Charbel's user avatar
  • 14.7k

1
2 3 4 5
68