Questions tagged [git-rev-parse]

Use this tag for questions related to the git rev-parse command.

TL;DR: It converts a user-friendly reference like a branch name or HEAD to a full 40 character string like 28e86d32396289f852565c1a91730ad29d30abcd

See What does git rev-parse do? and the git docs entry for more details.

14 questions
457
votes
4 answers

What does git rev-parse do?

What does git rev-parse do? I have read the man page but it raised more questions than answers. Things like: Pick out and massage parameters Massage? What does that mean? I'm using as a resolver (to SHA1) of revision specifiers, like git rev-parse…
talles
  • 14,356
  • 8
  • 45
  • 58
3
votes
2 answers

Git find first non-local commit

Related: List Git commits not pushed to the origin yet git rev-parse HEAD gives me the latest commit in the workspace, but this can be a locally committed githash. In other words, a commit which is not pushed to remote yet how do I find the latest…
ealeon
  • 12,074
  • 24
  • 92
  • 173
2
votes
1 answer

Refer to parent of matched commit when using :/ syntax

The :/ syntaxallows you to match commits using regular expressions. E.g., to create a fixup commit for an earlier commit that contains the string 'Add widget', you can write: git commit --fixup ':/Add widget' Is there way to apply modifiers such as…
larsks
  • 277,717
  • 41
  • 399
  • 399
2
votes
2 answers

How to trim part of git rev-parse output from windows slave

I have the below output from my jenkinsfile.groovy (running on windows slave): command: def commitHash = bat(returnStdout: true, script: "git rev-parse HEAD").trim() commitHash…
arielma
  • 1,308
  • 1
  • 11
  • 29
2
votes
2 answers

Wrong Commit Hash with git rev-parse

I'm having some weird behavior with git right now. I have a codebase that has a commit tagged v2.3.0 If I run git log, I can see that my latest commit hash is: commit b2ee576083607b7ba451b72642a77ca3309e4ac9 (HEAD, tag: v2.3.0, origin/staging,…
leedle
  • 156
  • 2
  • 4
2
votes
1 answer

How do Git's @{upstream} and @{push} differ?

What's the difference between a Git branch's @{upstream} and the newer @{push}? As I understand it @{upstream} is the branch's upstream tracking ref, and @{push} is the ref a push will push to. To my intuition those are the same thing. Checking…
henry
  • 4,244
  • 2
  • 26
  • 37
2
votes
1 answer

.NET Core 2.1 using environment variables for build using git hash in dotnet core command CLI

How to embed git hash to use in dotnet build command to be able to catch it and put in build pipeline process as an environment variable ${hash} and use ${hash} environment variable in appsettings..json files for ASP.NET Core 2.1 WebAPI?
1
vote
1 answer

git rev-parse origin/branch_name randomly fails with "fatal: ambiguous argument ... unknown revision or path not in the working tree"

I use the following commands to push local branch changes to remote branch (in some automated script): #while being on main branch git checkout -B new_local_branch_unix_timestamp #optionally modify some files # check if there are modified…
rok
  • 9,403
  • 17
  • 70
  • 126
1
vote
1 answer

Refer to a git commit by commit message headline

How can I refer to a git commit by the text / words in its commit message headline? I want to avoid: Mouse copy / paste of a commit hash from git log Typing of commit hexadecimal digits
Tom Hale
  • 40,825
  • 36
  • 187
  • 242
0
votes
1 answer

How to assign the git rev-parse output to ENV variable in dockerfile?

I am trying to add versioning to my program, and I want the version string to be the short commit hash of my repo. The following command gives me exactly the string I want: git rev-parse --short HEAD. So far, I was able to set it as an environment…
hadar
  • 1
0
votes
0 answers

Commit hash in python using subprocess.check_output()

I wish to get the current commit hash in my python script using the following command: subprocess.check_output(['git', 'rev-parse', 'HEAD']) It returns an empty string for some reason. When run on another system it seems to return the commit hash…
0
votes
2 answers

What does git rev-parse HEAD:XXX do?

I've read the man page of git-rev-parse, but still have no idea of what does this command do. Let's say I have a git project that has a structure like this: MyProject ├── Folder1 ├── Folder2 ├── .git If I run git-rev-parse HEAD then I can get a…
P. Tsin
  • 435
  • 4
  • 14
0
votes
1 answer

Identify the version (SHA) of the last time a specific file was committed

I have a big project with multiple scripts and files all maintained with GIT. In all those files, there is a document on which I want to print the commit version (SHA) associated with this file. My Google search gave me: git rev-parse --short…
Bastien
  • 3,007
  • 20
  • 38
0
votes
2 answers

Traverse through HEAD to access all git commits

I am trying use the below command to access the commit ID's for all the commits on my branch. git rev-parse HEAD~0 --> Gives the latest commit git rev-parse HEAD~1 --> Gives the previous commit git rev-parse HEAD~n I need to access all the commit's…
Sharif
  • 1