Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking out multiple branches: fatal: ambiguous argument 'master': unknown revision or path not in the working tree #296

Closed
terencedignon opened this issue Jul 7, 2020 · 7 comments · Fixed by #301

Comments

@terencedignon
Copy link

terencedignon commented Jul 7, 2020

Hi Checkout team,

I'm trying to checkout both the PR branch & master so diffs can be run on the two and only modified files are linted. This returns a fatal error because master is not recognized. I think this PR (#155) addresses the issue, but I'm not sure.

Is there a way to hack around this in the meantime? Thank you!

fatal: ambiguous argument 'master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

Config

name: Javascript Presubmit

on: [pull_request]

jobs:
  lint:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: Install npm packages
        run: npm install
      - name: Lint
        # Run ESLint on JS and JSX files that diff from master.
        run: git diff-index --name-only master | grep -E "(.*)\.(jsx|js)$" | xargs npx eslint
@terencedignon
Copy link
Author

terencedignon commented Jul 7, 2020

Update, changing checkout@v2 to checkout@v1 and modifying the run script works:
git diff --name-only origin/master HEAD | grep -E "(.*)\.(jsx|js)$" | xargs npx eslint

@ericsciple
Copy link
Contributor

If you set fetch-depth: 0 it will fetch all history for all branches and tags.

@ericsciple
Copy link
Contributor

Updating the readme with this PR

@jcopps
Copy link

jcopps commented Jul 26, 2022

If you set fetch-depth: 0 it will fetch all history for all branches and tags.

Will this still require v1 instead of v2?

@syedfaizan
Copy link

@jcopps yes, i was trying v2 and v3, it didn't work, after seeing this comment, i changed to v1 and it works!!

@sanderdg
Copy link

sanderdg commented Dec 13, 2022

Why is this issue not being addressed? I cannot switch to v1 since it's not under my control so now I'm stuck.

edit: Found a solution:

git fetch origin master:refs/remotes/origin/master
git diff --name-only "feature/my-branch..origin/master"

@TomaszOrchowskiCodibly
Copy link

@sanderdg

I had similar problem with

fetch-depth: 0

i figured out that also works in v3 but i have to add origin like

git rev-list --count origin/main..$(git branch --show-current)

and this works

ajmeese7 added a commit to meese-os/meeseOS that referenced this issue Sep 25, 2023
linikerpapke added a commit to linikerpapke/voltz-challenge that referenced this issue Oct 4, 2023
linikerpapke added a commit to linikerpapke/voltz-challenge that referenced this issue Oct 4, 2023
martin-g added a commit to martin-g/bioconda-utils that referenced this issue Oct 13, 2023
The `Run tests` jobs were broken with bioconda@1ae4126
The problem is that the project uses `fetch-depth: 1` (the default) and
thus has no branch history.
Using `fetch-depth: 0` would fetch the whole history for **all**
branches and tags, which would be unnecessary.

Refs:
- actions/checkout#296
- actions/checkout#301

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
martin-g added a commit to martin-g/bioconda-utils that referenced this issue Oct 13, 2023
The `Run tests` jobs were broken with bioconda@1ae4126
The problem is that the project uses `fetch-depth: 1` (the default) and
thus has no branch history.
Using `fetch-depth: 0` would fetch the whole history for **all**
branches and tags, which would be unnecessary.

Refs:
- actions/checkout#296
- actions/checkout#301

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
(cherry picked from commit e3c24c6)
martin-g added a commit to martin-g/bioconda-utils that referenced this issue Oct 13, 2023
The `Run tests` jobs were broken with bioconda@1ae4126
The problem is that the project uses `fetch-depth: 1` (the default) and
thus has no branch history.
Using `fetch-depth: 0` would fetch the whole history for **all**
branches and tags, which would be unnecessary.

Refs:
- actions/checkout#296
- actions/checkout#301

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
(cherry picked from commit e3c24c6)
johanneskoester pushed a commit to bioconda/bioconda-utils that referenced this issue Oct 23, 2023
The `Run tests` jobs were broken with
1ae4126
The problem is that the project uses `fetch-depth: 1` (the default) and
thus has no branch history.

Refs:
- actions/checkout#296
- actions/checkout#301

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>

---------

Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
scholz-timo added a commit to veto-party/baum that referenced this issue Jul 29, 2024
WeiChungHsu added a commit to WeiChungHsu/android-cuttlefish that referenced this issue Aug 22, 2024
WeiChungHsu added a commit to google/android-cuttlefish that referenced this issue Aug 23, 2024
lonelydev added a commit to lonelydev/pagerduty-schedules that referenced this issue Oct 2, 2024
- Add a GitHub Actions workflow to validate commits with commitlint
- set fetch-depth to 0
- based on actions/checkout#296
lonelydev added a commit to lonelydev/pagerduty-schedules that referenced this issue Oct 2, 2024
- Add a GitHub Actions workflow to validate commits with commitlint
- set fetch-depth to 0
- based on actions/checkout#296
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants