not to create new commit-id on gerrit - gerrit

I use two gerrit now.
When I push the code, I used to this.
git add
git commit -m "Update OOOO module, fix the bug A1-09000"
git push origin HEAD:refs/for/master
-----modify sth.
git add src/editedfile.c
git commit --amend
git push origin HEAD:refs/for/master
The problem is, it works only for a gerrit A. The other gerrit B always create a new commit-id. So I couldn't push changes for a new patch set.
I tried to put this.
scp -p -P 29417 id#gerritUrl:hooks/commit-msg .git/hooks
Problems on gerrit A
Create patch set is ok. But always asking a gerrit password on push. Even I register ssh key.
Problems on gerrit B
Can not create a patch set. but it does not ask password.
For me, more important proejct is on the gerrit B. So I need to push the new patch set. What is the problem of this?

After git commit check the commit message itself by git log. the changeId should be placed in the commit msg. I think the first commit did not contain changeId either. You can deny commits without changeId - it can be set in the project admin page. Also check the content of the downloaded hook in .git/hooks. commit-msg should have a header in the beginning. For the first problem, can you ssh into gerrit A without password? this behavior only happens at push?

Related

Can I save a list of reviewers in Gerrit?

Gerrit 2.13.8-4-gb79a18cfff-dirty
I just joined a new project.
Every time I push committed code to Gerrit I need to manually feed it a list of reviewers for my ticket/issue.
Is there any way I can save this list in Gerrit or does the owner of the project need to do that ( how? )
Thanks.
A solution would be to have the reviewers plugin installed/configured in your Gerrit server. Only the Gerrit administrators can do that.
See more info about Gerrit plugins here.
See more info about the reviewers plugin here.
Yes, you can set push options in your Git configuration to automatically add reviewers for every push. For example, to add john.doe as reviewer for every change pushed from this repository:
git config --local --add push.pushOption r=john.doe
The above approach requires Git 2.16+, though. See also Can I set push-options (git push -o “…”) in git config?.
If you are still on an older Git version locally, you could pass the option via a Bash or Git alias or even use the old syntax for push options, e.g.:
alias gpr 'git push origin HEAD:refs/for/master%r=john.doe'

Laravel + Angular project commit error: src refspec master does not match any

There is a project that is coded using angular and laravel. I downloaded it from server to my local. After doing some cleaning, tried to commit to git. But I see the same error everytime which I specified on header.
After some tests, when I was looking here for the same errors, I couldn't find any solution. There are my steps:
1. cd sysGarden
2. git init
3. git add .
4. git commit -m "first commit"
5. git remote add origin git#github.com:biyro02/sysGarden.git
6. git push -u origin master
After the last step I saw errors. I have an account on github. You can look: https://github.com/biyro02/sysGarden
On git bash, I have logged in with my user name and password. Everything ok but I see errors. Please help me. This is my first git commit. I am ready to share my all infos. Just, I want to exceed this problem.
Edit: I execute "git branch" result: * master
Edit 2: I got the error below:
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists
You should be able to resolve this issue by running the following commands again.
git add .
git commit -m 'Commit Message Here'
git push -u origin master
You may also try git push origin HEAD:master and if you need more information to share you can try git show-ref to see more verbose your local branch information.
This issue likely happens because of unstaged / untracked files or because your current branch is different to the branch you are pushing but I cannot be certain.

Jira: assign an existing git branch to an issue

In JIRA connected with STASH you can create a feature branch for an issue using the button 'create branch'. (That is nice to track the commits in this issue.)
If a developer started working but did not know that there is such an issue he did not click the 'create branch'.
Is there any possibility to assign an existing git branch to an issue?
ex-Stash developer here.
Yes and no. Creating the branch though the UI is just a convenience. The important thing is that the name contains the JIRA key. If only one developer is working on the branch, it's fairly easy to just rename (delete + add) a branch with the appropriate name.
git checkout old-branch
git push -u origin old-branch:JIRAKEY-1234-something
git push origin :old-branch
Does that help?
Update
As for january 2017 if you have an already exiting branch and you want to attach it to a Jira Issue you can do the following:
Checkout to the branch you want to rename
Execute the following command
git branch -m JIRA_ISSUE_ID-Whatever
Assuming that mine Jira issue is SO-01 I can do the following:
git branch -m SO-01-Whatever
This will change the name locally, push it to remote with:
git push origin :old_name
Command Syntax
git branch (-m | -M) [<oldbranch>] <newbranch>
Related question for more info
This is no longer the case. With a common setup between bitbucket and Jira, simply including the issue ID in the commit message will create a link between the commit, and thus the branch, and the issue in Jira.
I just tested the theory that having the Jira ID in the branch name creates an automatic link.
It does.
To see the effect, you have to push a commit. Then the branch will show up in the Jira.
The branch shows up in Jira, but to get an individual commit to show up in Jira I have to refer to the Jira ID in the commit message.
The web interface option is to branch off a branch but merge back to master in the pull request.
eg:
click create branch in jira
set the repo, branch type and name to what you want
set the branch from to be the existing branch
click create
when creating a pull request set the destination branch to what you want eg master
If you include the JIRA-ID in the branch name, by creating out of an existing commit, all you have to do is:
git push --set-upstream origin <new-branch-name>
and the branch is attached to the JIRA ticket.
Just add a new commit with the Jira issue key in the commit message

SourceTree Ignore Pull after master reset (Hard)

I have reset my master to a certain commit (hard) in the sourceTree. The master has been reset but I still get the a message to pull (4 behind). On pull all the previous unwanted changes has been added to my repo. How can I ignore any pull requests after Hard rest?
This is because those changes are on your remote. A hard reset will just discard the changes in your local branch and in your working copy.
To fix this you'd either have to do a force push, but this isn't recommended as it's dangerous and pisses off other devs working on that repo, and is generally dangerous. Your other option is going to be resetting the changes to a particular commit. This would look something like this:
git reset -q <SHA> -- <filename>
git checkout <SHA> -- <filename>
Where is the commit which you'd want to revet to, and is the file.
You can do this in SourceTree by context-clicking on a file at a specific commit and hitting "Reset to commit".
Hope that helps.

Need some basic github help

I am trying to learn github to deploy a webpage. Here are the steps I am taking:
git checkout master
git pull origin master
git checkout –b my-awesome-branch
Do some work, do a git status to check on everything, everything is ok.
git add .
git commit –m "awesome message here"
git push origin my-awesome-branch
git checkout integration
git merge my-awesome-branch
git push origin integration
cap development deploy
this will push a file to the dev server we have so people can look at it - this worked fine for me you won't be able to see the link but it generates something like this:
http://dev.mywebsite.com/events/email/welcome
Let's go live (pretending there are no further changes)
git checkout master
git merge my-awesome-branch
git push origin master
cap production deploy
In theory, the file should push to the live website (which would be http://mywebsite.com/events/email/welcome) but that webpage is not created when i cap production deploy.
Another developer more familiar with this system says :
It looks like you forked "my party events" repo and have pushed the
master there. You'll want to push master to the upstream remote (the
main "my party events", or my_events repo.)
I don't follow this step. Can anyone follow this logic? If so, do you have a suggestion for me on what i may be doing wrong? Any help is appreciated.
If you have a forked branch on Github, that means you have a copy of the entire git repo under your name. Check your Github account to verify this.
To do this, go to https://github.com/your-github-user-name-here. On the left side, look for "my-party-events" (assuming that's the repo name). Underneath it, look for "forked from xyz/my-party-events".
If you don't see 'forked from ...', then you're the original owner of that repo. This shouldn't be the case.
If you do see 'forked from ...', then you have a copy under your name (that's what a fork is). Any changes you make to a fork don't affect the original repo.
If you're with me up to here, there's 2 ways you can go.
Via Git (Recommended)
Whenever you did a git pull or git push earlier, you were specifying origin, which is a human-readable name for a repo that you set up earlier. The repo address actually looks like this
git#github.com:your-user-name/project-name.git
As you can see, referring to it by a nickname like 'origin' is way easier to remember.
Assuming you have write access to the main project repo, you can just add another repo to your config. Make sure you have write access before attempting this, otherwise you're just wasting your time. Ask your coworker if you're not sure.
Lets say you wanted to nickname the repo as 'production', you would do this
git remote add production git#github.com:PROJECT_OWNER/project-name.git
The git repo address looks almost identical to your fork repo. It differs only by username. On the front page of all Github projects, the repo address is in a text field. It's next to the "SSH | HTTPS | Git Read-only" buttons. Get the address from there, replace it in the command above, and finally, do this in your command line
git push production master
From now on, you can just git push production master, which is pretty simple. If you don't have write access, then you'll have to submit changes via pull requests.
Through the Website
You can submit a pull request to the repo you forked from. A pull request asks the original repo admin to include changes you've made on your fork.
To submit a pull request, click on your project fork from your projects page. Look for the 'Pull Request' icon near the top right. That should take you to a page where you can choose the target and source branches.

Resources