Pagine

Thursday, 11 May 2017

How to migrate a branch in a new git repository

For a reason with almost zero probability but not impossible you may find yourself in the situation of having to migrate a single branch between two git repositories.
Follow these steps for migration:
 git clone <old_repo>
 git checkout <branch_target>
 git remote set-url origin <new_repository>
 git push origin <branch_target>
Now clean your workspace, clone the old repository and remove branch target.
See the previous post "How to delete local and remote branches with git" for more details about delete of a branch.

Tuesday, 9 May 2017

How to change svn user in TortoiseSVN client (Windows)


TortoiseSVN is a Subversion Client for Windows. After first svn checkout it requires the credentials to be stored. These credential is used for future operations (update, commit, etc...). If you use a second repository but a different svn account, TortoiseSVN uses automatically the credentials already stored and you will probably have an error access (403 forbidden).
The soluntion is the following:
  1. Right click
  2. TortoiseSVN
  3. Settings
  4. Saved Data
  5. Authentication data - Clear
  6. Svn operation (update, commit, etc...)
  7. Put new credentials

Monday, 8 May 2017

Svn Error: E155036 - When it happens

The svn error with code "E155036" is thrown when you use a local copy created before an upgrade of svn server.
A typical scenario is the following:
  1. A developer creates his local copy.
  2. SVN Admin performs the svn server upgrade
  3. After the upgrade, the developer tries to use his local copy and svn throws the error "E155036".
The solution is very easy and it is shown in error description but the focus of this post is on the scenario just described.

> svn status
svn: E155036: Please see the 'svn upgrade' command
svn: E155036: Working copy '/home/user/myproject' is too old (format 10, create
d by Subversion 1.6)
> svn upgrade
Upgraded '.'
Upgraded 'A'
Upgraded 'A/B'
Upgraded 'A/B/C'
.... 

Friday, 5 May 2017

How to rename a tag with git

The tag rename operation is not atomic but more steps are needed.
1) Create the tag with new name from old tag:
 git tag <new_tag> <old_tag>
2) Delete the old tag from local repository:
 git tag -d <old_tag>
3) Delete the old tag from remote repository:
 git push origin :refs/tags/<old_tag>
4) Push the local tag in remote repository:
 git push --tags
5) Lastly synchronize the tag list among local and remote repositories:
 git fetch -f

Thursday, 4 May 2017

How to create a branch with git

Create a local branch from current branch:
 git checkout -b <new_branch>
Otherwise you can use the following command:
 git checkout -b <new_branch> <start_point>
where the start point can be an other branch or a tag.
Now if the new branch must become a remote branch then use also the following command:
 git push origin <new_branch>

Wednesday, 3 May 2017

How to delete local and remote branches with git

Delete a local branch

Use the following command to delete a branch already merged:
 git branch -d <branch_name>
If the branch is not merged, use -D option to force the delete:
 git branch -D <branch_name>

Delete a remote branch

Use one of following commands to delete a remote branch (valid with git version 1.7 or later):
 git push origin --delete <branch_name>
or
 git push origin :<branch_name>

Monday, 1 May 2017

Git - How to get the branch remote list

Who knows the basic features of git know that branches can be of two types: local and remote.
Use the following command for the list of local branches:
 git branch
Instead use the option '-r' for remote branches:
 git branch -r
Finally the option '-a' for full list (local and remote branches):
 git branch -a