align axis with direction

I am trying rotate object so his Y-axis always points in direction of another object, and continue moving forward at the same time. However, if I use following code, object always rotates and moving toward world forward axis, not local, even if on start, he was facing in another direction.

swingDirection = transform.forward*acceleration;
        Vector3 testPos = transform.position + swingDirection*Time.deltaTime;
        float newLenghtSq = (testPos - linePoint).sqrMagnitude;
        if (newLenghtSq > lineLenghtSq)
        {
            testPos = linePoint + (testPos - linePoint).normalized * lineLenght;
        }
        Vector3 myUp = (transform.position - linePoint);
        transform.rotation = Quaternion.FromToRotation(Vector3.up, -myUp);
        //transform.position = testPos+transform.forward*acceleration;
            Vector3 moveDir = (testPos-transform.position) + transform.forward * acceleration;
            controller.Move(moveDir);

Hi,
Do you mean, you want to point the y-axis to another object (Look at?) and Move forward, along the Z-axix? You could try to look at the other object and rotate back - something like this (untested):

public Transform _anotherTransform;

Transform _transform;
float _degree = 90; // not sure, if this is the direction you need 
float _acceleration = 10;

void Start() {
    _transform = transform; // just for performance...
}

void Update {
    _transform.LookAt(anotherTransform);
    _transform.Rotate(Vector.up * _degree); 
    controller.Move(Vector.forward * acceleration);  
}

Wrap your object into another empty game object in such a way to make its up direction to coincide with the forward direction of the wrapper, then you can simply use

transform.LookAt(target);