Wednesday, November 29, 2017

How push or sync commits to a different branch

Let’s say we have created a branch yesterday and committed some changes to master branch.
If we want to make both the branches even.
  1. Option 1 -> is to delete and recreate the branch again from master.
  2. Option 2 -> checkout to master branch and run below command.
    git push origin master:<new_branch>
All the commits are identified by a unique ID.So we don’t need to mention the parent branch of the commit if we know its ID.So, If we want to add only a specific commit, then run below command from the target branch checked out.
git checkout -b new_branch origin/new_branch -> If branch never checked out locally.
git checkout new_branch -> If already checked out locally.
git cherry-pick <commit-ID>
Reference: https://www.devroom.io/2010/06/10/cherry-picking-specific-commits-from-another-branch/

How to add windows node to Jenkins

Login to Jenkins portal and click on Manage Jenkins link.
Scroll down and click on Manage Nodes.
Click on new node link left side.
1.png
Provide node details and press OK.
2
Click on save after providing below details.
3.png
4
Now login to the Jenkins portal on the machine which we want to add as node.
And then go to the nodes section and click on the node we added.
Click on the launch button.
5.png
6.png
7.png
Select the below window and hold alt key to get the options enabled.
8
9.png
Click on refresh, so you can see the node added successfully.
10
Download document: Add windows node to jenkins

How to disable auto launch of server manager

On the windows server machines, I am taking 2012 as an example, server manager launches automatically once we login to the machine.
To disable that we need to set below option.
  1. Open the “Server Manager”.
  2. Select “Manage” on the top bar.
  3. Select “Server Manager Properties” from the drop down menu.
    1
  4. Select the option “Do not start Server Manager automatically at logon”.
    2

This can also be set using the below registry.
[HKEY_CURRENT_USER\Software\Microsoft\ServerManager]
“DoNotOpenServerManagerAtLogon”=dword:00000001
And the reverse option is
[HKEY_CURRENT_USER\Software\Microsoft\ServerManager]
“DoNotOpenServerManagerAtLogon”=dword:00000000
You can set the same key in HKLM to set it for all users.But we should not keep this registry value “DoNotOpenServerManagerAtLogon” in HKCU at that time as the User key will be given preference.

Temporary Directories for RDP sessions on windows

By default, In windows server machines, when you login to the machines using Remote Desktop Session, it will create a temporary sub directory in the temp folder and redirects to this when we tried to access temp folder using %temp%
1
As you see the number marked at the end.
2
We can disable this behavior using the below setting in group policy.
For server 2003:
group policy:  Administrative Templates\Windows Components\Terminal Services\Temporary folders . If you don’t select Do not use temporary folders per session, then these TEMP subdirectories are created.
For server 2008 and above:
group policy:  Computer Configuration\Policies\Administrative Templates\Windows Components\Remote Desktop Services\Remote Desktop Session Host\Temporary folders
3

The following tool, from Microsoft TechNet, allows management of Group Policy via the command line, and thus scripting as well:

The registry used is:
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services]
“PerSessionTempDir”=dword:00000000

Enable or Disable projects in Jenkins

By default, you don’t have any option to enable/disable a job or project in Jenkins.
The default view will be like this.
1
If you observe, there is no disable/enable option.
To make it available, install the Extra Columns Plugin
Then create a new view of type “List View” and select your projects, then click on add column and select the below one.
2
This will give you a button to enable/disable the project in the view created.
2

Remote Desktop not connecting but able to ping

Sometimes, even if the remote machine is working with ping command but we won’t be able to connect it when we try to connect with mstsc (Remote Desktop Connection).
First and Foremost, check whether below setting is enabled in system properties -> Remote Settings.
Capture
If it is already enabled then check whether below firewall inbound rules are enabled.
Capture
Then it should work.
You should disable the firewall if it is a test machine ðŸ™‚
If you still not able to do that, then you need to check the network settings for the Antivirus installed on the remote machine.
For example, In eset Nod32 antivurs, we have option called personal firewall which should be configured properly or disabled.

Git Remote end Hung Up error

When you get a remote hung up error while trying to push the local repository to GitHub server, 2 cases arises.
1. Your local network issues.
2. GitHub upload size limit.
For the first case, to have a resume option, you can use the tool like Sourcetree.
For the second case, even though the individual file size limit is maintained, there is a size limit for pushing the repository but not one the complete code size.
The limit is 2 GB now.
If your repository is of more size.Then we can push in partitions.
This option is available with the help of below command, where the number of commits to be published are limited only till the commit code we specify.
git push <repo_name> <commit ID>:refs/heads/<branch_name>
Let’s say we have 1000 commits and we specify the 50th commit, then the commits from 1 to 50 will be pushed and later are skipped, if we specify the 150th commit later, then as already 50 commits are pushed, the commit range 51 to 150 will be pushed.