3,375 questions
Best practices
1
vote
3
replies
61
views
How to make one commit of several changes on GitHub when working via the GUI and not using command line
First of all, yes, I have read all topics here related to my question. But other questions are based on changes made locally and using command line.
I'm asking about this specific situation: working ...
4499
votes
42
answers
5.7m
views
How do I delete a commit from a branch?
How do I delete a commit from my branch history? Should I use git reset --hard HEAD?
2729
votes
23
answers
1.5m
views
How to branch from a previous commit
If I have an n number of commits, how can I create a branch from the n-3 commit?
1756
votes
21
answers
1.4m
views
Changing git commit message after push (given that no one pulled from remote)
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 ...
1244
votes
33
answers
736k
views
How can one change the timestamp of an old commit in Git?
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 ...
1775
votes
19
answers
1.4m
views
How can I revert multiple Git commits?
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 ...
2
votes
1
answer
70
views
How to wait for replication at mariadb transaction commit?
I have a MariaDB cluster made with Galera and my clients use MaxScale with RW router.
I'm having an issue because the application has something this sequential steps:
Start trx1
Insert new record
...
2042
votes
14
answers
795k
views
How to undo "git commit --amend" done instead of "git commit"
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 ...
1217
votes
18
answers
497k
views
How to list all commits that changed a specific file?
Is there a way to list all commits that changed a specific file?
489
votes
21
answers
336k
views
GitHub pull request showing commits that are already in target branch
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 ...
1030
votes
8
answers
420k
views
How to amend a commit without changing commit message (reusing the previous one)?
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?
943
votes
10
answers
632k
views
git add only modified changes and ignore untracked files
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 "....
1140
votes
7
answers
892k
views
How can I push a specific commit to a remote, and not previous commits?
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?
285
votes
21
answers
715k
views
Error "Updates were rejected because the remote contains work that you do not have locally"
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 ...
507
votes
17
answers
879k
views
Remove specific commit
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 ...
356
votes
22
answers
444k
views
Git error on commit after merge - fatal: cannot do a partial commit during a merge
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 ...
523
votes
14
answers
162k
views
How can I view prior commits with git blame?
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 ...
209
votes
14
answers
550k
views
How to add multiple files to Git at the same time
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 ...
602
votes
12
answers
331k
views
How to edit log message already committed in Subversion?
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 ...
723
votes
5
answers
375k
views
How can I reference a commit in an issue comment on GitHub?
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?
321
votes
11
answers
182k
views
How to remove the first commit in git?
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?
422
votes
10
answers
103k
views
Start a Git commit message with a hashmark (#)
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 ...
889
votes
3
answers
597k
views
How to commit my current changes to a different branch in Git [duplicate]
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 ...
0
votes
1
answer
133
views
Show differences between commits with respect to a base
We use a common git strategy:
branch from main to a feature branch.
do commits in feature.
if main progresses, merge it to feature.
merge feature to main.
I want to view the changes that happened ...
269
votes
6
answers
250k
views
How can I delete the last n commits on GitHub and locally?
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 ...
483
votes
2
answers
183k
views
Git number of commits per author on all branches
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. ...
511
votes
4
answers
419k
views
Find a commit on GitHub given the commit hash
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 ...
786
votes
1
answer
504k
views
How do I create a new Git branch from an old commit? [duplicate]
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 ...
238
votes
10
answers
90k
views
See "real" commit date / time in github (hour/day)
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 ...
304
votes
4
answers
176k
views
Install specific git commit with pip
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/...
1
vote
1
answer
3k
views
How to Use GitHub Copilot for Commit Message Generation
I am interested in using GitHub Copilot to help generate commit messages for my project. I have heard that it can provide suggestions based on specific commit message instructions. However, I am not ...
339
votes
5
answers
91k
views
How can I find the commit in which a given file was added?
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:
...
11
votes
3
answers
19k
views
Git Error: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400
git push -u origin main
error: RPC failed; HTTP 400 curl 22 The requested URL returned error:
400
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up ...
23
votes
4
answers
37k
views
How to clone a repository from a specific commit ID?
I'm trying to clone using HTTPs a repository (sample.com/component.git) but from a specific commit ID.
Should I fetch the repoistory, then checkout that commit ID and finally clone it, or what would ...
244
votes
9
answers
262k
views
Editing the git commit message in GitHub
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 ...
265
votes
5
answers
171k
views
How to commit no change and new message?
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?
7
votes
1
answer
3k
views
IntelliJ not showing diff in commit window
I use Windows and IntelliJ IDEA 2024.2.4. (Ultimate Edition)
I've been looking at all options and I do not find anything where I can change this behaviour... When I commit I see a window which does ...
236
votes
6
answers
241k
views
Git commit in terminal opens VIM, but can't get back to terminal
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 ...
299
votes
3
answers
197k
views
How do you move a commit to the staging area in git?
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 ...
0
votes
1
answer
45
views
Create commit from several files of another branch
Suppose I have a branch B1 that added files A, B, C, ..., Z.
Suppose I am at branch B2.
What I want is to get a subset of files (say A, E, I, O, U) from the latest state of B1 and create a commit in ...
0
votes
1
answer
447
views
Long time commiting file Intellij IDEA
I'm have one update file in project. But it's very long time updated. Antivirus windows deactivated. What could be the problem? Intellij IDEA Community.
I'm try off my antivirus and reload Intellij ...
25
votes
3
answers
45k
views
How to change an old commit message? [duplicate]
I need to change an old commit message. Considering that I've made a few other commits afterwards, is there a way to change it, via git or directly on GitHub, without interfering with the other ...
227
votes
8
answers
118k
views
Mercurial: how to amend the last commit?
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 ...
174
votes
10
answers
229k
views
GIT commit as different user without email / or only email
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 ...
62
votes
3
answers
59k
views
What would be a good commit message for updating package versions using Conventional Commits?
Following Conventional Commits what would be the best <type> for commits regarding package version changes (upgrades/updates)?
E.g.: feat: Bump React version to "16.13.1"
E.g.: feat: ...
447
votes
5
answers
266k
views
How to move certain commits to be based on another branch in git?
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 ...
275
votes
4
answers
617k
views
Merging 2 branches together in Git
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 ...
186
votes
8
answers
148k
views
How to git ignore ipython notebook checkpoints anywhere in repository
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 ...
0
votes
1
answer
114
views
Why on Azure DevOps after pull request on repo one appear 1 behind
Azure DevOps Repos, situation is really simple, we have
Branch Master ---+---+ Head
Branch Develop ---+---+ Head + ... + changes
After some commit on Develop, we create pull request from ...
122
votes
11
answers
78k
views
Getting "CHECKOUT can only be performed on a version resource" when trying to commit using Eclipse subversive plugin
I'm using Eclipse Juno on Mac 10.7.5, SVN 1.7 and the Eclipse Subversive plugin. Occassioanlly, when I try and commit changes from my project (by right clicking on the project from the package ...