YouTrack doesn't show linked commits in VCS Changes tab - version-control

I properly set up YouTrack & GitLab integration and it seems to be working. I used this tutorial: https://www.jetbrains.com/help/youtrack/standalone/Integration-with-Version-Control-Systems.html
But when I mention issue ID in commit message
$ git commit -m "my message #PROJ-1"
after push, it doesn't show in YouTrack at VCS Changes tab. I have to add the commit hash manually (via YouTrack) and only then it's ok.
Am I missing something?

For this integration to work, YouTrack server has to be accessible by GitLab server, because the later notifies the former about commits. Manually adding changes work another way: YouTrack initiates connections to GitLab.

Related

Cannot push GitHub changes form Atom editor

I've been giving GitHub's Atom editor a try but am struggling to get the GitHub integration to work. I cloned a repository from my account and cannot push the changes back to GitHub.
I just added a test file called "otherfile.html", committed those changes, and tried pushing it. It comes up with a login for GitHub twice were I enter my username ans a Personal Access Token (I have two-factor authentication setup). Then it gives me this error message:
The tip of your current branch is behind its remote counterpart. Try pulling before pushing again. Or, to force push, hold cmd or ctrl while clicking.
Not sure if it is related, but the GitHub tab says this:
No Pull request could be found fo the branch master on the repository gabrielewig/gabrielewig.github.io
You can manually pin a GitHub pull request to the current branch by entering its URL:
Any help would be appreciated! The exact repo can be found here: https://github.com/gabrielewig/gabrielewig.github.io
First, switch to command line to see what git status give you.
And do a git pull if it still mention your master branch is behind its remote counterpart.
Second, check your git config credential.helper value.
On Windows for instance, the GCM helper would need your username/password (not PTA) in order to create a PTA.
Finally, do check "Improved pull request experience in GitHub for Atom" (Sept. 2018)
we’ve added a pull request list view. Now you can see the most recent pull requests in the GitHub tab Ctrl+8 with information such as:
Author’s avatar
Title of the pull request
Pull request number
CI status
“Last Updated” information
In addition to seeing more information about your existing pull requests, you can also open a new pull request directly from Atom.

Can we create a pull request using command-line tooling?

As my browser was crashing I was not able to create a pull request from GitHub UI, I was trying to create a pull request from git console but didn't found any way to create a pull request.
I have also searched for the same over the net but most of the tutorials suggested to create a pull request from UIs only. I just want to be able to handle the pull request like creation, rejection, approved and merging without the browser. Please suggest.
git and github are separate products. github is a service that happens to use git, but it is not part of git, its UI is not a git interface, and git does not have any special support for github functionality.
There is a little potential confusion here, because there are "pull requests" - an integrated feature of github having to do with branch workflow - and there is git request-pull, a seemingly lesser-known feature of git which creates a text message you could send to another repository maintainer to request that they pull changes from your repository.
Naming confusion aside, the "pull request" you want is a feature of github, not git; and so git itself (including git console and any git UI tool) have no command for this. You have to use a github-supplied interface, and AFAIK that means the web UI.
To open a pull request from the command line, you can install the hub set of command-line tools that GitHub supports. This will allow you to create a pull request from a repository with:
hub pull-request
I'm not aware of any similar tools for managing pull requests, though.
git add -p
then
git commit -m "message"
then
git push origin "your_branch"
the pull request will be created in github

Commit message hook on github

I am trying to setup a pre-receive hook in github that I used to use on STASH. In STASH, I had a pre-receive hook that used to enforce "A custom commit message that should have a JIRA number included in it".
Now, I am trying to understand what would be the best way to do something similar on github. If I split it up, it would be:
Requiring a custom commit message.
Every commit should include an existing JIRA.
Enforce this on any pull request as well.
Eg: TEST-1 Adding the first commit message.
Can anybody here help me, how can this be done ?
GitHub only offers webhooks, which allows you to listen to and react to certain events, including the push.
But that only allows you to react to a push (like a post-receive hook would), not to prevent it.
You could build a listener to that push event which would:
examine the latest commit just pushed
reset to HEAD~1 if the commit doesn't follow the expected policy (push --force)
But that would be tricky for the user who initially pushed that commit to realize that said commit just disappeared from the GitHub repo.
A better solution would be to setup a bare repo in a server where you could setup that pre-receive hook: if that commit passes, then a post-receive hook would push it to the intended GitHub repo.
But depending on your team, it might be difficult to setup a repo which is accessible by everyone.

How to push unsynced commits to GitHub?

I have a GitHub source control tool added to my copy of Visual Studio 2013 and when I right click on the solution and make a commit it says created the commit locally. When I try to sync the commit with the server, the sync button is greyed out.
My question is how do I set it up or what steps do I take so that the commit is pushed to the server?
It looks like you do not have the upstream remote / branch configured for this branch. Visual Studio operates as if the "push.default" configuration is set to "upstream".
If you go to the branches page, this branch should be listed under the "Unpublished" branches section. From that page, you can choose to "publish" this branch by right clicking on the unpublished branch and selecting publish in the resulting context menu. This will push the branch to the origin remote (with a branch of the same name as your local branch) and set the upstream tracking information for this branch. From then on, you can push and fetch from the Unsynced Commits page.
Here is a screen capture of where you need to go to publish an unpublished branch:
You need to add the online GitHub repo as a remote in your local git repo.
On the command line, that's git remote add origin <urL>; I don't know if the VS git UI exposes this.
We use Atlassian Stash but also found the Visual Studio UI a bit confusing at first. The sequence that works for us, using only the UI, is as follows:
First you have to add your "username" and e-mail address in the Git global settings via Team Explorer > Home > Git > Git Settings
On the "Solution Explorer" tab, right click on the solution and "Add Solution to Source Control" and choose Git.
On the "Team Explorer" tab, click on the repo you just created and go to branches
Choose the master branch, right click on it and choose "Publish" - you will be asked for the remote URL whereupon after you enter it, you will get a username/password prompt (for the remote server i.e. GitHub, Stash, etc.)
All this is doing is git push origin masterbut Microsoft chose to make it confusing by giving it another name.
Wait for the "publish" to be completed (there will be a file transfer status shown in the UI)
Once it is completed, go to the commits tab and you will see that all the options for Push/Pull/Fetch etc are available
Note: If you create another branch locally, you will have to push, er "publish", that one as well before the remote knows about it.
Final note: Visual Studio will not create projects and repos for you on the remote. You have to make sure the repo is setup on the remote before you can push a branch to it.
Weird issue: We found that if you try to push to a branch but fail (due to incorrect URL or a permissions issue) that we had to go back to the command prompt to "fix" the remote configuration for the repo/branch. This is using the standard git command:
git remote add origin https://myuser#stash.mycompany.com/scm/myproject/myrepo.git
After you publish a branch as in #jamill's answer you may run into this.
In Team Explorer, I was able to publish a branch, but then I could not do anything. Pull and Push were grayed out as shown:
So I did Actions > Open Command Prompt. Then Type:
git push origin My_Branch_Name
After doing this I could see the branch and my commit in my remote. (Github or whatever in your case). Also when running the command, the output said,
remote: Create pull request for My_Branch_Name:
If you want to keep this branch and merge it into master, then you can create a pull request on your remote. Otherwise as in my case I want to abandon the branch. You don't have to do anything.

Getting started with GitHub and Eclipse (spring source toolsuite 2.7.1)

I am new with both Git and GitHub so please bear with me.
I have an empty repository on GitHub with an automatically created branch (gh-pages), which, I understand, is supposed to be used with GitHub's pages functionality.
Now what I would like to do is to create and eclipse project from which I could commit/push to this repository.
What is confusing me that I can't see any option to create a remote branch on github. I suppose pushing my source to gh-pages won't be a good idea. BTW, I also don't understand why the GitHub pages is feature is implemented as a branch? Aren't branches supposed to be merged with each other at some point. Clearly it wouldn't make any sense to merge github pages into my project. Wouldn't it be better to have a folder within my project for this purpose.
I googled and found this link but being a git noob I am not sure if that's what I want to do. I would like to use Eclipse as my primary interface to git and github only falling back to command line or other interfaces when there is no other option.
OK I think I have figured it out. Basically, what you need is to define a remote ref that need not exist before hand.
Create a project
Team->Share it to a local repository
In the repository view (Window->Show View-> Git -> Repositories) select the local repository and right click on remotes
Select new remote (configure push). Type origin in the remote name. Press OK
Change URL. Copy/paste the ssh uri from github. Select ssh protocol (make sure you have ssh key defined in eclipse SSH preferences, and uploaded to github)
Now the last part is to add Ref mapping. Click on Add.. in ref mapping section of screen. And enter refs/heads/master in both local and remote branches.
Or may be the refs/heads/master on both side isn't a good idea :)
I see, cloning a github repo that doesn't have gh-pages branch is simpler as it automatically creates this remote fetch spec
Remote Fetch Specification +refs/heads/*:refs/remotes/origin/*
Maybe this is what I need to enter in the step 6 above
Ok as it turned out the original idea of "refs/heads/master in both local and remote branch" was correct. Pushing with this configuration is showing my changes in git hub correctly. The second option on the other hand is failing silently.
Branches typically are used in the way you described, but nothing says they must be used that way. This is just the way github chose to let you manage your page content, and it works quite well. It's kind of similar to hosting multiple repos on one SVN server.
As for creating new repos, if you create a repo in github and then clone it, you'll have an empty repo locally that already points to github with a remote named "origin". This is a convenient way to start out, since you don't have to mess with adding a remote yourself. At this point, your repo has no commits and no branches in it. When you make the first commit, it will automatically establish a branch named "master". I don't know how eclipse is set up by default, but from the command line with default settings, you have to explicitly push new branches to a remote or else they won't get pushed at all. I.e. making the first commit and doing git push will just fail with a message like "No refs in common and none specified; doing nothing". Instead, you have to git push origin master to tell it to establish the "master" branch in remote "origin" (aka github). Thereafter, just a git push will work fine.
Hope that clears up some of your confusion.